diff --git a/_mysql-server-site.yml b/_mysql-server-site.yml new file mode 100644 index 0000000..4bb13fa --- /dev/null +++ b/_mysql-server-site.yml @@ -0,0 +1,7 @@ +--- +- import_playbook: debops/mariadb_server.yml +- import_playbook: debops/mariadb-custom-db.yml + +# Import all other group playbooks in this file... + +... diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..dc6f990 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +inventory=./hosts +group_vars=./group_vars diff --git a/data/db-dumps/.gitignore b/data/db-dumps/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/data/db-dumps/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/debops/files/etc/nginx-master-proxy/conf.d/sample-filecloud.conf.example b/debops/files/etc/nginx-master-proxy/conf.d/sample-filecloud.conf.example index 9163615..a55b2bb 100644 --- a/debops/files/etc/nginx-master-proxy/conf.d/sample-filecloud.conf.example +++ b/debops/files/etc/nginx-master-proxy/conf.d/sample-filecloud.conf.example @@ -3,7 +3,7 @@ server { server_name domain; client_max_body_size 0; location / { - proxy_pass http://lxc_host; + proxy_pass http://site_name; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; diff --git a/debops/files/etc/nginx-master-proxy/conf.d/sample-s3.conf.example b/debops/files/etc/nginx-master-proxy/conf.d/sample-s3.conf.example index b81918f..22fcdae 100644 --- a/debops/files/etc/nginx-master-proxy/conf.d/sample-s3.conf.example +++ b/debops/files/etc/nginx-master-proxy/conf.d/sample-s3.conf.example @@ -5,7 +5,7 @@ server { client_max_body_size 0; proxy_buffering off; location / { - proxy_pass http://lxc_host:9000; + proxy_pass http://site_name:9000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; diff --git a/debops/files/etc/nginx-master-proxy/conf.d/sample-website.conf.example b/debops/files/etc/nginx-master-proxy/conf.d/sample-website.conf.example index 0cc8c98..dd235a8 100644 --- a/debops/files/etc/nginx-master-proxy/conf.d/sample-website.conf.example +++ b/debops/files/etc/nginx-master-proxy/conf.d/sample-website.conf.example @@ -2,7 +2,7 @@ server { listen 80; server_name domain; location / { - proxy_pass https://lxc_host; + proxy_pass https://site_name; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; diff --git a/debops/files/etc/nginx-master-proxy/conf.d/sample-youtrack.conf.example b/debops/files/etc/nginx-master-proxy/conf.d/sample-youtrack.conf.example index 0f349d0..70ec232 100644 --- a/debops/files/etc/nginx-master-proxy/conf.d/sample-youtrack.conf.example +++ b/debops/files/etc/nginx-master-proxy/conf.d/sample-youtrack.conf.example @@ -2,7 +2,7 @@ server { listen 80; server_name domain; location / { - proxy_pass http://lxc_host:8080; + proxy_pass http://site_name:8080; access_log off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; @@ -13,7 +13,7 @@ server { proxy_http_version 1.1; } location /api/eventSourceBus { - proxy_pass http://lxc_host:8080; + proxy_pass http://site_name:8080; access_log off; proxy_cache off; proxy_buffering off; diff --git a/debops/nginx.yml b/debops/nginx.yml index a052f73..08a56e4 100644 --- a/debops/nginx.yml +++ b/debops/nginx.yml @@ -24,11 +24,11 @@ nginx_ocsp: False nginx_worker_processes: auto nginx__servers: - - name: '{{ lxc_host }}' + - name: '{{ site_name }}' type: php - root: '/var/www/{{ lxc_host }}' + root: '/var/www/{{ site_name }}' public_dir_name: '' @@ -38,10 +38,12 @@ location_list: - pattern: '/' - options: rewrite ^/.*$ /index.php last; locations: - pattern: '~ ^/*.-backend/' options: set $upstream unix:/run/php7.4-fpm-backend.sock; + options: try_files /index.html @october; + - pattern: '@october' + options: rewrite ^/.*$ /index.php last; - pattern: '~* ^(?!/index).*\.php$' options: return 403; @@ -74,17 +76,17 @@ post_tasks: - name: Default index.html template: - src: var/www/lxc_host/index.html.j2 - dest: '/var/www/{{ lxc_host }}/index.html' + src: var/www/site_name/index.html.j2 + dest: '/var/www/{{ site_name }}/index.html' mode: 0644 - owner: '{{ lxc_host }}' + owner: '{{ site_name }}' - name: Copy normalized.css template: - src: var/www/lxc_host/normalize.css - dest: '/var/www/{{ lxc_host }}/' + src: var/www/site_name/normalize.css + dest: '/var/www/{{ site_name }}/' mode: 0644 - owner: '{{ lxc_host }}' + owner: '{{ site_name }}' roles: diff --git a/debops/php-prod.yml b/debops/php-prod.yml index 07eab65..6f5d4fd 100644 --- a/debops/php-prod.yml +++ b/debops/php-prod.yml @@ -10,10 +10,8 @@ | combine(inventory__group_environment | d({})) | combine(inventory__host_environment | d({})) }}' + vars: - php__version_preference: [ 'php7.4' ] - php__sury: '{{ ansible_local.php.sury - |d(ansible_distribution_release in [ "buster" ]) | bool }}' php__sury_apt_key_id: '{{ php__sury_apt_key_id_map[ansible_distribution] }}' php__sury_apt_repo: '{{ php__sury_apt_repo_map[ansible_distribution] }}' php__sury_apt_key_id_map: @@ -36,7 +34,6 @@ # mbstring требует только некоторые пакеты в laravel # bcmath - нужно для работы парсера Excel файлов на одном из проектов # Laravel/OctoberCMS: intl, redis - php__packages: [ 'curl', 'xml', 'gd', 'zip', 'mbstring', 'mysql', 'bcmath', 'intl', 'redis' ] php__composer_upstream_enabled: '{{ True if (ansible_distribution_release in [ "buster" ]) @@ -58,6 +55,9 @@ pm: static pm_max_children: 3 + vars_files: + - ./../vars/php.yml + pre_tasks: - name: Apply keyring configuration for php environment diff --git a/debops/system_users.yml b/debops/system_users.yml index 7f3deed..c9f42c8 100644 --- a/debops/system_users.yml +++ b/debops/system_users.yml @@ -20,7 +20,7 @@ post_tasks: - name: Change starship character to dollar sign - shell: "sed -i 's/#/\\\\$/g' /home/{{ lxc_host }}/.config/starship.toml" + shell: "sed -i 's/#/\\\\$/g' /home/{{ site_name }}/.config/starship.toml" args: executable: /bin/bash diff --git a/debops/templates/var/www/lxc_host/index.html.j2 b/debops/templates/var/www/site_name/index.html.j2 similarity index 100% rename from debops/templates/var/www/lxc_host/index.html.j2 rename to debops/templates/var/www/site_name/index.html.j2 diff --git a/debops/templates/var/www/lxc_host/normalize.css b/debops/templates/var/www/site_name/normalize.css similarity index 100% rename from debops/templates/var/www/lxc_host/normalize.css rename to debops/templates/var/www/site_name/normalize.css diff --git a/group_vars/all.yml b/group_vars/all.yml index 3387441..eefda29 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -6,4 +6,7 @@ remote_user: root keyring__keyserver: hkp://keyserver.ubuntu.com:80 # Add further variables which apply to all servers to this file... +secret__levels: '.' + +site_name: '{{ site_name | d(lxc_host) }}' ... diff --git a/nginx-site.yml b/nginx-site.yml index b7b8905..f7e3b6a 100644 --- a/nginx-site.yml +++ b/nginx-site.yml @@ -7,12 +7,14 @@ - import_playbook: debops/root_account.yml - import_playbook: debops/sudo.yml - import_playbook: debops/system_users.yml -- import_playbook: debops/mariadb.yml +- import_playbook: debops/mariadb_server.yml +- import_playbook: debops/mariadb-custom-db.yml - import_playbook: debops/php-prod.yml - import_playbook: debops/nginx.yml - import_playbook: debops/nodejs.yml - import_playbook: debops/redis.yml - import_playbook: playbooks/own/var-www-set-ownerships.yml +- import_playbook: playbooks/own/node-version-manager.yml # Import all other group playbooks in this file... diff --git a/playbooks/own/node-version-manager.yml b/playbooks/own/node-version-manager.yml new file mode 100644 index 0000000..1b3eb5e --- /dev/null +++ b/playbooks/own/node-version-manager.yml @@ -0,0 +1,9 @@ +--- + +- name: Installing node version manager + hosts: [ 'debian10' ] + tasks: + - name: Install nvm + become: true + become_user: '{{ site_name }}' + shell: 'wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash' diff --git a/playbooks/own/var-www-set-ownerships.yml b/playbooks/own/var-www-set-ownerships.yml index 97e1364..340e5d5 100644 --- a/playbooks/own/var-www-set-ownerships.yml +++ b/playbooks/own/var-www-set-ownerships.yml @@ -4,4 +4,4 @@ hosts: [ 'debian10' ] tasks: - name: Set ownerships to /var/www dir - shell: 'chown -R {{ lxc_host }}:{{ lxc_host }} /var/www' + shell: 'chown -R {{ site_name }}:{{ site_name }} /var/www' diff --git a/root-account.yml b/root-account.yml new file mode 100644 index 0000000..96076e3 --- /dev/null +++ b/root-account.yml @@ -0,0 +1,9 @@ +--- +- import_playbook: playbooks/own/locales.yml +- import_playbook: debops/tzdata.yml +- import_playbook: debops/yadm.yml +- import_playbook: debops/root_account.yml + +# Import all other group playbooks in this file... + +... diff --git a/run-playbook.sh b/run-lxc-playbook.sh similarity index 88% rename from run-playbook.sh rename to run-lxc-playbook.sh index ce59bd3..2965696 100755 --- a/run-playbook.sh +++ b/run-lxc-playbook.sh @@ -4,7 +4,7 @@ LXC_HOST=$2 PLAYBOOK=$3 usage() { - echo "Usage: run-playbook.sh server lxc_host playbook" + echo "Usage: run-lxc-playbook.sh server lxc_host playbook" echo "server - main proxmox server IP address and lxc_host that the name of lxc container" echo "lxc_host - name of lxc container" echo "playbook - playbook file" @@ -35,7 +35,7 @@ if [[ ! -f "$PLAYBOOK" ]]; then fi COMMAND=$(cat <