You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.1 KiB
YAML
92 lines
2.1 KiB
YAML
---
|
|
|
|
- name: Install dependencies for mysql database
|
|
apt:
|
|
state: present
|
|
name:
|
|
- mariadb-server
|
|
- mariadb-client
|
|
notify: restart mysql
|
|
|
|
- name: Install ansible dependencies for configuring
|
|
pip:
|
|
state: present
|
|
name:
|
|
- PyMySQL
|
|
|
|
- meta: flush_handlers
|
|
|
|
- name: Lock root user for localhost
|
|
mysql_user:
|
|
user: "root"
|
|
password: "{{ mysql_root_password }}"
|
|
host: "localhost"
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
login_user: root
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
- name: Remove test users
|
|
mysql_user:
|
|
user: ""
|
|
host_all: yes
|
|
state: absent
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
login_user: root
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
- name: Lock root user for ::1
|
|
mysql_user:
|
|
user: "root"
|
|
password: "{{ mysql_root_password }}"
|
|
host: "::1"
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
login_user: root
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
- name: Lock root user for 127.0.0.1
|
|
mysql_user:
|
|
user: "root"
|
|
password: "{{ mysql_root_password }}"
|
|
host: "127.0.0.1"
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
login_user: root
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
- name: Disable public root user access
|
|
mysql_user:
|
|
user: "root"
|
|
host: "{{ inventory_hostname }}"
|
|
state: absent
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
login_user: root
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
- name: Remove mysql test database
|
|
mysql_db:
|
|
db: "test"
|
|
state: absent
|
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
|
login_user: root
|
|
login_password: "{{ mysql_root_password }}"
|
|
|
|
- name: Configure innodb of mysql
|
|
copy:
|
|
dest: "/etc/mysql/conf.d/innodb.cnf"
|
|
content: |
|
|
[mysqld]
|
|
innodb_large_prefix=ON
|
|
innodb_file_format=barracuda
|
|
innodb_file_per_table=ON
|
|
notify:
|
|
- restart mysql
|
|
|
|
- name: Configure query cache of mysql
|
|
template:
|
|
src: query_cache.cnf
|
|
dest: "/etc/mysql/mariadb.conf.d/query_cache.cnf"
|
|
owner: root
|
|
group: root
|
|
mode: "u=rw,g=r,o=r"
|
|
notify:
|
|
- restart mysql
|