Initial commit
[ta/infra-ansible.git] / conflicts-with-openstack-ansible / galera-install.yml
1 ---
2 # Copyright 2014, Rackspace US, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # cmframework.requires: initial_poweroff_hosts.yml, memcached-install.yml
16
17 - name: Galera container config
18   hosts: galera_all
19   gather_facts: "{{ osa_gather_facts | default(True) }}"
20   serial: 1
21   tasks:
22     - include: common-tasks/os-log-dir-setup.yml
23       vars:
24         log_dirs:
25           - src: "/openstack/log/{{ inventory_hostname }}-mysql_logs"
26             dest: "/var/log/mysql_logs"
27       when: reinitialized_nodes is not defined or (reinitialized_nodes is defined and hostname in reinitialized_nodes)
28     - include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
29       vars:
30         list_of_bind_mounts: "{{ galera_container_bind_mounts }}"
31         extra_container_config_no_restart:
32           - "lxc.start.order=10"
33       when: reinitialized_nodes is not defined or (reinitialized_nodes is defined and hostname in reinitialized_nodes)
34     - include: common-tasks/unbound-clients.yml
35       static: no
36       when:
37         - hostvars['localhost']['resolvconf_enabled'] | bool
38         - reinitialized_nodes is not defined or (reinitialized_nodes is defined and hostname in reinitialized_nodes)
39   environment: "{{ deployment_environment_variables | default({}) }}"
40   tags:
41     - galera
42
43 - name: Install galera server
44   hosts: galera_all
45   gather_facts: "{{ osa_gather_facts | default(True) }}"
46   serial: 1
47   roles:
48     - role: "galera_server"
49       when: reinitialized_nodes is not defined or (reinitialized_nodes is defined and hostname in reinitialized_nodes)
50     - role: "rsyslog_client"
51       rsyslog_client_log_rotate_file: galera_log_rotate
52       rsyslog_client_log_dir: "/var/log/mysql_logs"
53       rsyslog_client_log_files:
54         - /var/log/mysql.log
55         - /var/log/mysql.err
56       rsyslog_client_config_name: "99-galera-rsyslog-client.conf"
57       tags:
58         - rsyslog
59       when: reinitialized_nodes is not defined or (reinitialized_nodes is defined and hostname in reinitialized_nodes) 
60     - role: "system_crontab_coordination"
61       tags:
62         - crontab
63       when: reinitialized_nodes is not defined or (reinitialized_nodes is defined and hostname in reinitialized_nodes)
64   vars:
65     galera_server_id: "{{ inventory_hostname | string_2_int }}"
66     galera_wsrep_node_name: "{{ container_name }}"
67   environment: "{{ deployment_environment_variables | default({}) }}"
68   tags:
69     - galera
70
71 - name: Verify Galera cluster count.
72   hosts: baremetal-infra_hosts
73   tasks:
74     - set_fact:
75         given_cluster_count: "{{ groups['galera_all'] | count }}"
76
77     - name: Check the mysql cluster count
78       shell: mysql -e 'show status like "%wsrep_cluster_%";' | awk -F "wsrep_cluster_size" {'print $2'} |tr -d " \t\n\r"
79       register: cluster_count
80       until: cluster_count|success
81       failed_when: cluster_count.stdout != given_cluster_count
82   tags:
83     - galera
84