mysql-server/tasks/main.yml

62 lines
1.9 KiB
YAML
Raw Normal View History

2022-05-09 20:26:15 +03:00
---
- name: MySQL | Install packages
package:
name: "{{ mysql_packages }}"
state: present
- name: MySQL | Deploy main config
template:
src: "{{ mysql_main_conf.src }}"
dest: "{{ mysql_main_conf.dest }}"
mode: "{{ mysql_configs_mode }}"
owner: "{{ mysql_configs_user }}"
group: "{{ mysql_configs_user }}"
when: mysql_main_conf.src is defined
notify: MySQL | Restart
- name: MySQL | Deploy conf.d files
2022-05-09 20:53:21 +03:00
template:
2022-05-09 20:26:15 +03:00
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ mysql_configs_mode }}"
owner: "{{ mysql_configs_user }}"
group: "{{ mysql_configs_user }}"
with_items: "{{ mysql_confd }}"
notify: MySQL | Restart
- name: MySQL | Enable and start
service:
name: "{{ mysql_service_name }}"
state: started
2022-05-09 20:57:59 +03:00
enabled: yes
2022-05-09 20:26:15 +03:00
- name: MySQL | Create databases
mysql_db:
name: "{{ item.name }}"
state: "{{ item.state | d(omit) }}"
login_unix_socket: "{{ mysql_connection.unix_socket | d(omit) }}"
login_host: "{{ mysql_connection.host | d(omit) }}"
login_port: "{{ mysql_connection.port | d(omit) }}"
login_user: "{{ mysql_connection.user | d(omit) }}"
login_password: "{{ mysql_connection.password | d(omit) }}"
2022-05-09 20:26:15 +03:00
with_items: "{{ mysql_databases }}"
- name: MySQL | Create users
mysql_user:
name: "{{ item.name }}"
state: "{{ item.state | d(omit) }}"
2022-05-09 20:26:15 +03:00
password: "{{ item.password | d(omit) }}"
priv: "{{ item.priv | d(omit) }}"
login_unix_socket: "{{ mysql_connection.unix_socket | d(omit) }}"
login_host: "{{ mysql_connection.host | d(omit) }}"
login_port: "{{ mysql_connection.port | d(omit) }}"
login_user: "{{ mysql_connection.user | d(omit) }}"
login_password: "{{ mysql_connection.password | d(omit) }}"
2022-05-09 20:26:15 +03:00
with_items: "{{ mysql_users }}"
- name: unbound | Run handlers
meta: flush_handlers