61 lines
1.5 KiB
YAML
Raw Permalink 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
2023-09-15 22:01:42 +02:00
- name: Write config
ansible.builtin.template:
src: "mysql.cnf.j2"
dest: "/etc/mysql/mariadb.conf.d/50-server.cnf"
mode: "0644"
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 }}"
2023-09-15 22:01:42 +02:00
host: "{{ mysql.hostrange }}"
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
- 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
2023-09-15 22:01:42 +02:00
- name: restart mysql
ansible.builtin.service:
name: mysql
state: restarted
enabled: true
become: true