Create configuration database

This commit is contained in:
phil 2024-01-04 09:36:28 +01:00
parent bad798a2ee
commit 82012ccb99
5 changed files with 44 additions and 11 deletions

View file

@ -10,9 +10,12 @@ This role installs phpMyAdmin.
| `phpmyadmin_user` | System user to create | `pma` | | `phpmyadmin_user` | System user to create | `pma` |
| `phpmyadmin_blowfish_secret` | 32 bytes long plain-text password for cookie encryption | | | `phpmyadmin_blowfish_secret` | 32 bytes long plain-text password for cookie encryption | |
| `phpmyadmin_tmp` | Tmp directory | `/tmp` | | `phpmyadmin_tmp` | Tmp directory | `/tmp` |
| `phpmyadmin_database` | Name of phpMyAdmin configuration database | `phpmyadmin` |
| `phpmyadmin_database_password` | Password of configuration database user | |
| `phpmyadmin_hosts` | Array with hosts to connect to | *optional* | | `phpmyadmin_hosts` | Array with hosts to connect to | *optional* |
| `phpmyadmin_hosts.name` | Hostname of database host | * optional* | | `phpmyadmin_hosts.name` | Hostname of database host | *optional* |
| `phpmyadmin_host.address` | IP address of database host | *optional* | | `phpmyadmin_host.address` | IP address of database host | *optional* |
| `phpmyadmin_database_host` | Ansible hostname of the database host, use a list to create the configuration on multiple hosts | `localhost` |
## Playbook ## Playbook

View file

@ -1,3 +1,5 @@
--- ---
phpmyadmin_user: pma phpmyadmin_user: pma
phpmyadmin_tmp: /tmp phpmyadmin_tmp: /tmp
phpmyadmin_database: phpyadmin
phpmyadmin_database_host: localhost

31
tasks/configuration.yml Normal file
View file

@ -0,0 +1,31 @@
---
- name: "Configuration | Create configuration database"
community.mysql.mysql_db:
name: "{{ phpmyadmin_database }}"
state: present
login_unix_socket: "{{ mysql_socket }}"
login_user: root
delegate_to: "{{ phpmyadmin_database_host }}"
- name: "Configuration | Create database user"
community.mysql.mysql_user:
name: "{{ phpmyadmin_database }}"
host: "%"
password: "{{ phpmyadmin_database_password }}"
priv: "{{ phpmyadmin_database }}.*:ALL"
state: present
login_unix_socket: "{{ mysql_socket }}"
login_user: root
update_password: on_create
delegate_to: "{{ phpmyadmin_database_host }}"
- name: "Configuration | Copy configuration"
ansible.builtin.template:
src: pma.php.j2
dest: "/etc/phpmyadmin/conf.d/{{ inventory_hostname }}.php"
mode: "0644"
notify:
- Stop php-fpm-socket
- Stop php-fpm-service
- Start php-fpm-socket
- Start php-fpm-service

View file

@ -7,13 +7,6 @@
ansible.builtin.import_tasks: packages.yml ansible.builtin.import_tasks: packages.yml
tags: packages tags: packages
- name: Copy configuration - name: Configuration
ansible.builtin.template: ansible.builtin.import_tasks: configuration.yml
src: pma.php.j2 tags: configuration
dest: "/etc/phpmyadmin/conf.d/{{ inventory_hostname }}.php"
mode: "0644"
notify:
- Stop php-fpm-socket
- Stop php-fpm-service
- Start php-fpm-socket
- Start php-fpm-service

View file

@ -22,5 +22,9 @@ foreach ($hosts as $verbose => $host) {
$cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['compress'] = FALSE; $cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['controlhost'] = $host;
$cfg['Servers'][$i]['controlport'] = '3306';
$cfg['Servers'][$i]['controluser'] = '{{ phpmyadmin_dbuser }}';
$cfg['Servers'][$i]['controlpass'] = '{{ phpmyadmin_dbpass }}';
} }
{% endif %} {% endif %}