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
Jelle van der Waa 4bc660d6be
Remove zabbix-agent, zabbix roles
Zabbix has been replaced by Prometheus for monitoring our services.
2020-11-21 22:14:20 +01:00

41 lines
1.1 KiB
YAML

---
- name: install mariadb
pacman: name=mariadb,python-mysqlclient state=present
- name: initialize mariadb
command: mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
args:
creates: /var/lib/mysql/mysql
- name: configure mariadb
template: src=server.cnf.j2 dest=/etc/my.cnf.d/server.cnf owner=root group=root mode=0644
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 owner=root group=root mode=0644
no_log: true