47 lines
1.2 KiB
YAML
Raw Normal View History

---
- 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 }}"
password: "{{ wordpress.db_pass }}"
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