main.yml 1.62 KB
Newer Older
1
2
---
- name: install mariadb
3
  pacman: name=mariadb,python-mysqlclient state=present
4

5
6
7
8
9
10
11
- name: set the nocow attribute for btrfs
  file:
    path: "{{ mariadb_data_dir }}"
    state: directory
    attributes: '+C'
  when: filesystem == 'btrfs'

12
- name: initialize mariadb
13
  command: mysql_install_db --user=mysql --basedir=/usr --datadir="{{ mariadb_data_dir }}"
14
  args:
15
    creates: "{{ mariadb_data_dir }}/mysql"
16

17
- name: configure mariadb
18
  template: src=server.cnf.j2 dest=/etc/my.cnf.d/server.cnf
19
20
21
  notify:
    - restart mariadb

22
- name: start and enable the service
23
  service: name=mariadb state=started enabled=yes
24
25
26
27
28
29
30
31
32
33
34
35
36
37

- 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
38
  mysql_user: user=root host={{ item }} password={{ vault_mariadb_users.root }}
39
40
41
42
  with_items:
    - '127.0.0.1'
    - '::1'
    - 'localhost'
43
  no_log: true
44
45
46

- name: create client configuration for root
  template: src=client.cnf.j2 dest=/root/.my.cnf
47
  no_log: true
48

49
- name: configure zabbix-agent user
50
  mysql_user: user={{ zabbix_agent_mysql_user }} host=localhost password={{ vault_mariadb_users.zabbix_agent }}
51

52
53
# TODO: implement in ansible: grant process on *.* to 'zabbix_agent'@'localhost';

54
55
- 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