Compare commits

4 Commits

Author SHA1 Message Date
9f832c7fbf Single necessary change - remove sha-sum of composer version 2025-11-06 15:58:00 +03:00
f5b9100bc3 Use maximal acceptable ansible version vor correctly worked debops roles (with legacy buildin.include functions)
Set to currently newest version of debops
Use newest python version
Native way for create pma nginx config symlink
Correct disable local nginx host - appropriate dict item name field for preventing errors
2025-11-06 13:05:02 +03:00
2a1dc74039 Downgrade python and ansible versions, create python packages list and change mariadb upstream 2025-11-06 02:08:08 +03:00
aee0b1dab9 phpmyadmin fix 2025-11-05 20:23:07 +03:00
11 changed files with 63 additions and 41 deletions

9
hosts
View File

@ -9,16 +9,17 @@
# - You can enter hostnames or ip addresses # - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups # - A hostname/ip can be a member of multiple groups
# Check ansible facts: ansible all -m setup -a 'filter=ansible_domain' -e lxc_host=IP_ADDRESS
[lxc_templates] [lxc_templates]
#debian10 ansible_host=debian10.dedic106-dhcp.dimti.ru ansible_user=root #debian10 ansible_host=debian10.dedic106-dhcp.dimti.ru ansible_user=root
#debian10 ansible_host='{{ lxc_host }}' ansible_port=22230 #debian10 ansible_host='{{ lxc_host }}' ansible_port=22230
debian10 ansible_host='{{ lxc_host }}' debian10 ansible_host='{{ lxc_host }}'
[anygroup] [anygroup]
server1 ansible_host=192.168.0.1 #server1 ansible_host=192.168.0.1
server2 ansible_host=192.168.0.2 #server2 ansible_host=192.168.0.2
server3 ansible_host=192.168.0.3 #server3 ansible_host=192.168.0.3
server4 ansible_host=192.168.0.4 #server4 ansible_host=192.168.0.4
# Add your own groups here. Hosts can be added to multiple groups like so: # Add your own groups here. Hosts can be added to multiple groups like so:
# [anothergroup] # [anothergroup]

View File

@ -12,14 +12,15 @@
| combine(inventory__group_environment | d({})) | combine(inventory__group_environment | d({}))
| combine(inventory__host_environment | d({})) }}' | combine(inventory__host_environment | d({})) }}'
vars:
mariadb__flavor: '{{ ansible_local.mariadb.flavor|d(mariadb__flavor_map[ansible_distribution_release] | d("mariadb")) }}'
mariadb__upstream_version: '10.5'
vars_files: vars_files:
- ./../../vars/databases.yml - ./../../vars/databases.yml
vars:
mariadb__upstream_mirror: 'https://mirror.netcologne.de/mariadb/mariadb-{{ mariadb__upstream_version }}/repo/{{ ansible_distribution | lower }}'
mariadb__flavor: '{{ ansible_local.mariadb.flavor|d(mariadb__flavor_map[ansible_distribution_release] | d("mariadb")) }}'
mariadb__upstream_version: '11.8.3'
roles: roles:
- role: secret - role: secret

View File

@ -13,18 +13,16 @@
| combine(inventory__host_environment | d({})) }}' | combine(inventory__host_environment | d({})) }}'
vars: vars:
mariadb_server__upstream_mirror: 'https://mirror.netcologne.de/mariadb/mariadb-{{ mariadb_server__upstream_version }}/repo/{{ ansible_distribution | lower }}'
mariadb_server__flavor: '{{ ansible_local.mariadb.flavor mariadb_server__flavor: '{{ ansible_local.mariadb.flavor
|d(mariadb_server__flavor_map[ansible_distribution_release] | d("mariadb_upstream")) }}' |d(mariadb_server__flavor_map[ansible_distribution_release] | d("mariadb_upstream")) }}'
mariadb_server__upstream_version: '11.2' mariadb_server__upstream_version: '11.8.3'
mariadb_server__bind_address: '127.0.0.1' mariadb_server__bind_address: '127.0.0.1'
mariadb_server__mysqld_performance_options: mariadb_server__mysqld_performance_options:
'innodb_buffer_pool_instances': '{{ ansible_processor_vcpus | d(1) }}'
'innodb_buffer_pool_size': '{{ (ansible_memtotal_mb / 2) | int }}M' 'innodb_buffer_pool_size': '{{ (ansible_memtotal_mb / 2) | int }}M'
'innodb_log_file_size': '{{ (ansible_memtotal_mb / 2) / 4 | int }}M' 'innodb_log_file_size': '{{ ((ansible_memtotal_mb / 2) / 4) | int }}M'
'query_cache_type': '1' 'query_cache_type': '0'
'query_cache_size': '1M' 'join_buffer_size': '10M'
'query_cache_limit': '10M'
'join_buffer_size': '1M'
'performance_schema': 'ON' 'performance_schema': 'ON'
'skip-name-resolve': 'ON' 'skip-name-resolve': 'ON'
# mariadb_server__options: # mariadb_server__options:

View File

@ -32,6 +32,7 @@
# TODO: Replace [::]:443 to 443 and [::]:80 to 80 in site nginx config # TODO: Replace [::]:443 to 443 and [::]:80 to 80 in site nginx config
nginx_server_localhost: nginx_server_localhost:
enabled: False enabled: False
name: [ 'localhost', '127.0.0.1', '[::1]' ]
nginx_listen_port: [ '80' ] nginx_listen_port: [ '80' ]
nginx_listen_ssl_port: [ '443' ] nginx_listen_ssl_port: [ '443' ]
nginx__servers: nginx__servers:

View File

@ -1,5 +1,5 @@
--- ---
# https://docs.debops.org/en/stable-3.2/ansible/roles/php/getting-started.html#example-playbook
- name: Install and manage PHP environment - name: Install and manage PHP environment
collections: [ 'debops.debops', 'debops.roles01', collections: [ 'debops.debops', 'debops.roles01',
'debops.roles02', 'debops.roles03' ] 'debops.roles02', 'debops.roles03' ]
@ -10,6 +10,8 @@
| combine(inventory__group_environment | d({})) | combine(inventory__group_environment | d({}))
| combine(inventory__host_environment | d({})) }}' | combine(inventory__host_environment | d({})) }}'
vars_files:
- ./../../vars/php.yml
vars: vars:
php__sury_apt_key_id_map: php__sury_apt_key_id_map:
@ -55,9 +57,6 @@
pm: static pm: static
pm_max_children: 3 pm_max_children: 3
vars_files:
- ./../../vars/php.yml
pre_tasks: pre_tasks:
- name: Apply keyring configuration for php environment - name: Apply keyring configuration for php environment

View File

@ -7,17 +7,19 @@
hosts: [ 'debian10' ] hosts: [ 'debian10' ]
vars_files:
- ./../../vars/php.yml
tasks: tasks:
- name: Download and install composer - name: Download and install composer
when: (php_version is defined) when: (php_version is defined)
shell: |- shell: |-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php php composer-setup.php
php -r "unlink('composer-setup.php');" php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer mv composer.phar /usr/local/bin/composer
- name: Download and install composer - name: Downgrade composer to 1.x branch for legacy php versions
when: (php_version is defined and php_version == '7.4') when: (php_version is defined and php_version == '7.4')
shell: |- shell: |-
composer self-update 1.10.27 composer self-update 1.10.27

View File

@ -52,10 +52,11 @@
shell: |- shell: |-
echo "pma:$(openssl passwd -apr1 {{ lookup("password", secret + "/basic/" + site_name + "/pma " + "length=30")}} )" > /etc/nginx/passwords.d/pma.passwords echo "pma:$(openssl passwd -apr1 {{ lookup("password", secret + "/basic/" + site_name + "/pma " + "length=30")}} )" > /etc/nginx/passwords.d/pma.passwords
- name: 'Turning on pma web site nginx config' - name: Ensure pma nginx site is enabled (via symlink)
shell: |- ansible.builtin.file:
cd /etc/nginx/sites-enabled src: /etc/nginx/sites-available/pma.conf
ln -s ../sites-available/pma.conf ./ dest: /etc/nginx/sites-enabled/pma.conf
state: link
- name: 'Restarting nginx' - name: 'Restarting nginx'
shell: |- shell: |-

View File

@ -8,9 +8,9 @@
hosts: [ 'debian10' ] hosts: [ 'debian10' ]
vars: vars:
- phpmyadmin_version: 5.2.1 phpmyadmin_version: 5.2.1
# https://docs.ansible.com/ansible/latest/collections/community/general/random_string_lookup.html#keyword-parameters # https://docs.ansible.com/ansible/latest/collections/community/general/random_string_lookup.html#keyword-parameters
- blowfish_secret: "{{ lookup('community.general.random_string', length=32) }}" blowfish_secret: "{{ lookup('community.general.random_string', length=32) }}"
tasks: tasks:
- name: 'Download phpMyAdmin {{ phpmyadmin_version }} into var/www dir and uncompress' - name: 'Download phpMyAdmin {{ phpmyadmin_version }} into var/www dir and uncompress'
@ -28,14 +28,32 @@
mkdir tmp && sudo chown :33 tmp && chmod g+w tmp mkdir tmp && sudo chown :33 tmp && chmod g+w tmp
- name: 'Set cookie blowfish secret' - name: 'Set cookie blowfish secret'
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/replace_module.html ansible.builtin.lineinfile:
replace:
path: /var/www/phpmyadmin/config.inc.php path: /var/www/phpmyadmin/config.inc.php
regexp: "'blowfish_secret'] = ''" regexp: "^\\^\\$\\\\cfg\\\\[\\'blowfish_secret\\'\\\\] = '';"
replace: "'blowfish_secret'] = '{{ blowfish_secret | replace('\'', '\\\'') }}'\n\n$cfg['CookieSameSite'] = 'Lax';\n" line: "$cfg['blowfish_secret'] = '{{ blowfish_secret }}';"
owner: '{{ site_name }}'
group: '{{ site_name }}'
mode: '0640'
- name: 'Set CookieSameSite to Lax'
ansible.builtin.lineinfile:
path: /var/www/phpmyadmin/config.inc.php
# Добавляет строку в конец файла, если она еще не существует
line: "$cfg['CookieSameSite'] = 'Lax';"
insertafter: EOF # Вставляет в конец файла
# Необязательно, но полезно убедиться, что строки нет до добавления
create: false
owner: '{{ site_name }}'
group: '{{ site_name }}'
mode: '0640'
- name: 'Set MaxTableList' - name: 'Set MaxTableList'
replace: ansible.builtin.lineinfile:
path: /var/www/phpmyadmin/config.inc.php path: /var/www/phpmyadmin/config.inc.php
regexp: "^//$cfg['MaxRows'](.*)" regexp: "^//\\$cfg\\['MaxRows'\\]"
replace: "//$cfg['MaxRows']\1\n\n$cfg['MaxTableList'] = 500;\n" line: "$cfg['MaxTableList'] = 500;"
insertafter: "^//\\$cfg\\['MaxRows'\\]" # Вставит сразу после закомментированной строки
owner: '{{ site_name }}'
group: '{{ site_name }}'
mode: '0640'

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
ansible==8.7.0
netaddr==1.3.0

View File

@ -1,8 +1,7 @@
--- ---
# https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html
collections: collections:
- name: nginxinc.nginx_core - name: nginxinc.nginx_core
version: 0.8.0 version: 0.8.0
- name: https://github.com/debops/debops.git - name: debops.debops
type: git version: 3.2.5
version: d554096b5cb02f4c37f68d80d9103105dd5de34b

View File

@ -50,7 +50,7 @@ if [[ -z "$DOMAIN_NAME" ]]; then
fi fi
COMMAND=$(cat <<EOF COMMAND=$(cat <<EOF
ansible-playbook -e "lxc_host=${SERVER}" -e "initial_site_name=${SITE_NAME}" -e "domain_name=${DOMAIN_NAME}" -e runner=site ansible-playbook -e "lxc_host=${SERVER}" -e "site_name=${SITE_NAME}" -e "domain_name=${DOMAIN_NAME}" -e runner=site
EOF EOF
) )