phpmyadmin fix

This commit is contained in:
2025-11-05 20:23:07 +03:00
parent b70574767e
commit aee0b1dab9
2 changed files with 29 additions and 11 deletions

View File

@ -8,9 +8,9 @@
hosts: [ 'debian10' ]
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
- blowfish_secret: "{{ lookup('community.general.random_string', length=32) }}"
blowfish_secret: "{{ lookup('community.general.random_string', length=32) }}"
tasks:
- 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
- name: 'Set cookie blowfish secret'
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/replace_module.html
replace:
ansible.builtin.lineinfile:
path: /var/www/phpmyadmin/config.inc.php
regexp: "'blowfish_secret'] = ''"
replace: "'blowfish_secret'] = '{{ blowfish_secret | replace('\'', '\\\'') }}'\n\n$cfg['CookieSameSite'] = 'Lax';\n"
regexp: "^\\^\\$\\\\cfg\\\\[\\'blowfish_secret\\'\\\\] = '';"
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'
replace:
ansible.builtin.lineinfile:
path: /var/www/phpmyadmin/config.inc.php
regexp: "^//$cfg['MaxRows'](.*)"
replace: "//$cfg['MaxRows']\1\n\n$cfg['MaxTableList'] = 500;\n"
regexp: "^//\\$cfg\\['MaxRows'\\]"
line: "$cfg['MaxTableList'] = 500;"
insertafter: "^//\\$cfg\\['MaxRows'\\]" # Вставит сразу после закомментированной строки
owner: '{{ site_name }}'
group: '{{ site_name }}'
mode: '0640'

View File

@ -50,7 +50,7 @@ if [[ -z "$DOMAIN_NAME" ]]; then
fi
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
)