packweb-apache: don't regenerate phpMyAdmin suffix each time

This commit is contained in:
Jérémy Lecour 2018-09-09 22:59:56 +02:00
parent 46a9b4f43e
commit efcd2ed391
3 changed files with 31 additions and 5 deletions

View file

@ -16,6 +16,7 @@ The **patch** part changes incrementally at each release.
### Changed
### Fixed
* packweb-apache: don't regenerate phpMyAdmin suffix each time
### Security

View file

@ -8,5 +8,6 @@ packweb_apache_modphp: True
packweb_apache_fpm: False
packweb_phpmyadmin_suffix: ""
packweb_phpmyadmin_suffix_file: "/etc/evolinux/phpmyadmin_suffix"
packweb_mysql_variant: "debian"

View file

@ -23,16 +23,40 @@
changed_when: "'Disabling' in command_result.stderr"
when: pma_default_config.stat.exists
- name: "phpmyadmin suffix dirname '{{ packweb_phpmyadmin_suffix_file | dirname }}' exists"
file:
dest: "{{ packweb_phpmyadmin_suffix_file | dirname }}"
mode: "0700"
owner: root
group: root
state: directory
- name: set phpmyadmin suffix if provided
copy:
dest: "{{ packweb_phpmyadmin_suffix_file }}"
# The last character "\u000A" is a line feed (LF), it's better to keep it
content: "{{ packweb_phpmyadmin_suffix }}\u000A"
force: yes
when: packweb_phpmyadmin_suffix != ""
- name: generate random string for phpmyadmin suffix
command: "apg -a 1 -M N -n 1"
shell: "apg -a 1 -M N -n 1 > {{ packweb_phpmyadmin_suffix_file }}"
args:
creates: "{{ packweb_phpmyadmin_suffix_file }}"
- name: read phpmyadmin suffix
command: "tail -n 1 {{ packweb_phpmyadmin_suffix_file }}"
changed_when: False
check_mode: False
register: _random_phpmyadmin_suffix
check_mode: no
register: new_packweb_phpmyadmin_suffix
- name: overwrite packweb_phpmyadmin_suffix
set_fact:
packweb_phpmyadmin_suffix: "{{ _random_phpmyadmin_suffix.stdout }}"
when: packweb_phpmyadmin_suffix == ""
packweb_phpmyadmin_suffix: "{{ new_packweb_phpmyadmin_suffix.stdout }}"
- debug:
var: packweb_phpmyadmin_suffix
verbosity: 1
- name: enable phpMyAdmin config
blockinfile: