1 heat_template_version: pike
4 MySQL service deployment with pacemaker bundle
10 DockerMysqlConfigImage:
11 description: The container image to use for the mysql config_volume
15 description: Mapping of service endpoint -> protocol. Typically set
16 via parameter_defaults in the resource registry.
20 description: Dictionary packing service data
24 description: Mapping of service_name -> network name. Typically set
25 via parameter_defaults in the resource registry. This
26 mapping overrides those in ServiceNetMapDefaults.
35 MysqlClustercheckPassword:
40 description: Role name on which the service is applied
44 description: Parameters specific to the role
50 default: '/etc/ipa/ca.crt'
52 description: Specifies the default CA cert to use if TLS is used for
53 services in the internal network.
58 type: ../../containers-common.yaml
61 type: ../../../../puppet/services/pacemaker/database/mysql.yaml
63 EndpointMap: {get_param: EndpointMap}
64 ServiceData: {get_param: ServiceData}
65 ServiceNetMap: {get_param: ServiceNetMap}
66 DefaultPasswords: {get_param: DefaultPasswords}
67 RoleName: {get_param: RoleName}
68 RoleParameters: {get_param: RoleParameters}
72 internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
76 description: Containerized service MySQL using composable services.
78 service_name: {get_attr: [MysqlPuppetBase, role_data, service_name]}
81 - {get_attr: [MysqlPuppetBase, role_data, config_settings]}
82 - tripleo::profile::pacemaker::database::mysql_bundle::mysql_docker_image: &mysql_image_pcmklatest
86 data: {get_param: DockerMysqlImage}
87 expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
89 tripleo::profile::pacemaker::database::mysql_bundle::control_port: 3123
90 tripleo.mysql.firewall_rules:
91 '104 mysql galera-bundle':
100 tripleo::profile::pacemaker::database::mysql_bundle::bind_address:
103 "%{hiera('fqdn_$NETWORK')}"
105 $NETWORK: {get_param: [ServiceNetMap, MysqlNetwork]}
108 - internal_tls_enabled
110 tripleo::profile::pacemaker::database::mysql_bundle::ca_file:
111 get_param: InternalTLSCAFile
113 logging_source: {get_attr: [MysqlPuppetBase, role_data, logging_source]}
114 logging_groups: {get_attr: [MysqlPuppetBase, role_data, logging_groups]}
116 # BEGIN DOCKER SETTINGS #
119 puppet_tags: file # set this even though file is the default
123 - - "['Mysql_datadir', 'Mysql_user', 'Mysql_database', 'Mysql_grant', 'Mysql_plugin'].each |String $val| { noop_resource($val) }"
124 - "exec {'wait-for-settle': command => '/bin/true' }"
125 - "include ::tripleo::profile::pacemaker::database::mysql_bundle"
126 config_image: {get_param: DockerMysqlConfigImage}
128 /var/lib/kolla/config_files/mysql.json:
129 command: /usr/sbin/pacemaker_remoted
131 - dest: /etc/libqb/force-filesystem-sockets
135 - source: "/var/lib/kolla/config_files/src/*"
138 preserve_properties: true
139 - source: "/var/lib/kolla/config_files/src-tls/*"
143 preserve_properties: true
145 - path: /etc/pki/tls/certs/mysql.crt
149 - path: /etc/pki/tls/private/mysql.key
155 mysql_data_ownership:
158 image: {get_param: DockerMysqlImage}
161 # Kolla does only non-recursive chown
162 command: ['chown', '-R', 'mysql:', '/var/lib/mysql']
164 - /var/lib/mysql:/var/lib/mysql
168 image: {get_param: DockerMysqlImage}
171 # Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
178 - - 'if [ -e /var/lib/mysql/mysql ]; then exit 0; fi'
179 - 'echo -e "\n[mysqld]\nwsrep_provider=none" >> /etc/my.cnf'
180 - 'sudo -u mysql -E kolla_start'
181 - 'mysqld_safe --skip-networking --wsrep-on=OFF &'
182 - 'timeout ${DB_MAX_TIMEOUT} /bin/bash -c ''until mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" ping 2>/dev/null; do sleep 1; done'''
183 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "CREATE USER ''clustercheck''@''localhost'' IDENTIFIED BY ''${DB_CLUSTERCHECK_PASSWORD}'';"'
184 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "GRANT PROCESS ON *.* TO ''clustercheck''@''localhost'' WITH GRANT OPTION;"'
185 - 'timeout ${DB_MAX_TIMEOUT} mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown'
186 volumes: &mysql_volumes
188 - {get_attr: [ContainersCommon, volumes]}
190 - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
191 - /var/lib/config-data/puppet-generated/mysql/:/var/lib/kolla/config_files/src:ro
192 - /var/lib/mysql:/var/lib/mysql
194 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
195 - KOLLA_BOOTSTRAP=True
196 # NOTE(mandre) skip wsrep cluster status check
197 - KOLLA_KUBERNETES=True
202 - - 'DB_CLUSTERCHECK_PASSWORD'
203 - {get_param: MysqlClustercheckPassword}
207 - - 'DB_ROOT_PASSWORD'
210 expression: $.data.passwords.where($ != '').first()
213 - {get_param: MysqlRootPassword}
214 - {get_param: [DefaultPasswords, mysql_root_password]}
225 "/usr/bin/docker tag 'MYSQL_IMAGE' 'MYSQL_IMAGE_PCMKLATEST'"
227 MYSQL_IMAGE: {get_param: DockerMysqlImage}
228 MYSQL_IMAGE_PCMKLATEST: *mysql_image_pcmklatest
229 image: {get_param: DockerMysqlImage}
231 - /etc/hosts:/etc/hosts:ro
232 - /etc/localtime:/etc/localtime:ro
233 - /dev/shm:/dev/shm:rw
234 - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
235 - /usr/bin:/usr/bin:ro
236 - /var/run/docker.sock:/var/run/docker.sock:rw
250 - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
251 - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
253 TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation,galera_ready,mysql_database,mysql_grant,mysql_user'
254 CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::database::mysql_bundle'
255 image: {get_param: DockerMysqlImage}
257 - /etc/hosts:/etc/hosts:ro
258 - /etc/localtime:/etc/localtime:ro
259 - /etc/puppet:/tmp/puppet-etc:ro
260 - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
261 - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
262 - /dev/shm:/dev/shm:rw
263 - /var/lib/mysql:/var/lib/mysql:rw
265 - name: create /var/lib/mysql
270 get_attr: [MysqlPuppetBase, role_data, metadata_settings]
272 - name: get bootstrap nodeid
274 command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
275 register: bootstrap_node
276 - name: set is_bootstrap_node fact
278 set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
279 - name: Check cluster resource status
287 - name: Disable the galera cluster resource
292 wait_for_resource: true
295 until: output.rc == 0
296 when: is_bootstrap_node and galera_res|succeeded
297 - name: Delete the stopped galera cluster resource.
302 wait_for_resource: true
305 until: output.rc == 0
306 when: is_bootstrap_node and galera_res|succeeded
307 - name: Disable mysql service
309 service: name=mariadb enabled=no
310 - name: Remove clustercheck service from xinetd
312 file: state=absent path=/etc/xinetd.d/galera-monitor
313 - name: Restart xinetd service after clustercheck removal
315 service: name=xinetd state=restarted
317 - name: Get docker Mariadb image
319 docker_image: {get_param: DockerMysqlImage}
320 docker_image_latest: *mysql_image_pcmklatest
322 - name: Get previous Mariadb image id
323 shell: "docker images | awk '/mariadb.* pcmklatest/{print $3}'"
324 register: mariadb_image_id
326 - name: Get a list of container using Mariadb image
327 shell: "docker ps -q -f 'ancestor={{mariadb_image_id.stdout}}'"
328 register: mariadb_containers_to_destroy
329 # It will be recreated with the delpoy step.
330 - name: Remove any container using the same Mariadb image
331 shell: "docker rm -fv {{item}}"
332 with_items: "{{ mariadb_containers_to_destroy.stdout_lines }}"
333 - name: Remove previous Mariadb images
334 shell: "docker rmi -f {{mariadb_image_id.stdout}}"
337 - mariadb_image_id.stdout != ''
338 - name: Pull latest Mariadb images
339 command: "docker pull {{docker_image}}"
341 - name: Retag pcmklatest to latest Mariadb image
342 shell: "docker tag {{docker_image}} {{docker_image_latest}}"
344 # Got to check that pacemaker_is_active is working fine with bundle.
345 # TODO: pacemaker_is_active resource doesn't support bundle.