add galera.cnf for first node

This commit is contained in:
Egon Rijpkema 2017-10-17 17:12:52 +02:00
parent 9e877a1e63
commit fdb5320429
3 changed files with 23 additions and 0 deletions

View File

@ -4,3 +4,10 @@
become: True
roles:
- mariadb
vars:
hostname_node0: "{{ hostvars[groups['mariadb'][0]]['ansible_hostname'] }}"
hostname_node1: "{{ hostvars[groups['mariadb'][1]]['ansible_hostname'] }}"
hostname_node2: "{{ hostvars[groups['mariadb'][2]]['ansible_hostname'] }}"
ip_node0: "hostvars[groups['databases'][0]]['listen_ip'] | default(hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'])"
ip_node1: "hostvars[groups['databases'][1]]['listen_ip'] | default(hostvars[groups['databases'][1]]['ansible_default_ipv4']['address'])"
ip_node2: "hostvars[groups['databases'][2]]['listen_ip'] | default(hostvars[groups['databases'][2]]['ansible_default_ipv4']['address'])"

View File

@ -31,6 +31,20 @@
dest: /srv/mariadb/etc/mysql
mode: 660
- name: Set galara.cnf on first node if we have at least three nodes.
copy:
src: files/galera-master.cnf
dest: /srv/mariadb/etc/mysql/conf.d/galera.cnf
mode: 660
when: ansible_nodename == hostname_node0 and hostvars[groups['mariadb']]|length >= 3
- name: Set galara.cnf on other nodes if we have at least three nodes.
copy:
src: files/galera-slave.cnf
dest: /srv/mariadb/etc/mysql/conf.d/galera.cnf
mode: 660
when: ansible_nodename != hostname_node0 and hostvars[groups['mariadb']]|length >= 3
- command: systemctl daemon-reload
- name: make sure service is started

View File

@ -1,5 +1,7 @@
[databases]
ansible-test
ansible-test-2
ansible-test-3
[keystone]
ansible-test-3