You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
987 B
40 lines
987 B
---
|
|
|
|
- name: Install MySQL-python
|
|
yum:
|
|
name:
|
|
- MySQL-python
|
|
- mariadb
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
- name: Install MySQL-python
|
|
apt:
|
|
name:
|
|
- python-mysqldb
|
|
- mariadb-client
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
- name: Create MySQL database
|
|
mysql_db:
|
|
name: "{{ db_name }}"
|
|
login_host: "{{ db_server | default(mysql_server) }}"
|
|
login_user: sqladmin
|
|
login_password: "{{ mysql_admin_pass }}"
|
|
state: present
|
|
encoding: utf8mb4
|
|
collation: utf8mb4_general_ci
|
|
register: db_created
|
|
|
|
- name: Create MySQL User
|
|
mysql_user:
|
|
name: "{{ db_user }}"
|
|
password: "{{ db_pass }}"
|
|
priv: "{{ db_name }}.*:ALL"
|
|
append_privs: "{{ append_privs | default(False) }}"
|
|
host: "{{ ( db_server == 'localhost' ) | ternary('localhost', item ) }}"
|
|
login_host: "{{ db_server }}"
|
|
login_user: sqladmin
|
|
login_password: "{{ mysql_admin_pass }}"
|
|
state: present
|
|
with_items: "{{ ansible_all_ipv4_addresses }}"
|
|
|
|
|