2023-08-17 20:53:23 +02:00
|
|
|
---
|
|
|
|
- name: Install relevant packages
|
|
|
|
ansible.builtin.apt:
|
|
|
|
update_cache: true
|
|
|
|
cache_valid_time: 3600
|
|
|
|
name:
|
|
|
|
- mariadb-client
|
|
|
|
- mariadb-server
|
|
|
|
- python3-pymysql
|
|
|
|
state: present
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Set new root user password
|
|
|
|
community.mysql.mysql_user:
|
|
|
|
name: root
|
|
|
|
password: "{{ mysql_root_password }}"
|
|
|
|
check_implicit_admin: true
|
|
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Create wordpress user with password, grant wordpress permissions
|
|
|
|
community.mysql.mysql_user:
|
|
|
|
state: present
|
|
|
|
name: "{{ wordpress.db_user }}"
|
|
|
|
login_user: root
|
|
|
|
login_password: "{{ mysql_root_password }}"
|
2023-08-17 22:16:44 +02:00
|
|
|
password: "{{ wordpress_db_pass }}"
|
2023-08-17 20:53:23 +02:00
|
|
|
priv:
|
|
|
|
"wordpress.*": "ALL,GRANT"
|
|
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Store the config for task indempotency as written in the mysql collection docs
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "my.cnf.j2"
|
|
|
|
dest: "/root/.my.cnf"
|
|
|
|
mode: "0400"
|
|
|
|
become: true
|
|
|
|
notify: restart mysql
|
|
|
|
|
|
|
|
- name: Setup database for wordpress
|
|
|
|
community.mysql.mysql_db:
|
|
|
|
name: "{{ wordpress.db_name }}"
|
|
|
|
state: present
|
|
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
|
|
become: true
|