1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/roles/mariadb/tasks/main.yml
Giancarlo Razzolini fb2e7aebab roles/mariadb: Set the nocow attribute when using btrfs
To improve mysql performance when using btrfs, set the nocow attribute
before running initdb, so all the files created under the mysql datadir have
the attribute.
2020-08-03 09:37:03 +00:00

56 lines
1.6 KiB
YAML

---
- name: install mariadb
pacman: name=mariadb,python-mysqlclient state=present
- name: set the nocow attribute for btrfs
file:
path: "{{ mariadb_data_dir }}"
state: directory
attributes: '+C'
when: filesystem == 'btrfs'
- name: initialize mariadb
command: mysql_install_db --user=mysql --basedir=/usr --datadir="{{ mariadb_data_dir }}"
args:
creates: "{{ mariadb_data_dir }}/mysql"
- name: configure mariadb
template: src=server.cnf.j2 dest=/etc/my.cnf.d/server.cnf
notify:
- restart mariadb
- name: start and enable the service
service: name=mariadb state=started enabled=yes
- name: delete anonymous users
mysql_user: user='' host_all=yes state='absent'
- name: disallow remote root login
command: 'mysql -NBe "{{ item }}"'
with_items:
- DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')
changed_when: false
- name: drop test database
mysql_db: db=test state=absent
- name: set root password
mysql_user: user=root host={{ item }} password={{ vault_mariadb_users.root }}
with_items:
- '127.0.0.1'
- '::1'
- 'localhost'
no_log: true
- name: create client configuration for root
template: src=client.cnf.j2 dest=/root/.my.cnf
no_log: true
- name: configure zabbix-agent user
mysql_user: user={{ zabbix_agent_mysql_user }} host=localhost password={{ vault_mariadb_users.zabbix_agent }}
# TODO: implement in ansible: grant process on *.* to 'zabbix_agent'@'localhost';
- name: install zabbix mysql config
template: src=zabbix_agentd.my.cnf.j2 dest=/etc/zabbix/zabbix_agentd.my.cnf owner=zabbix-agent group=zabbix-agent mode=0600