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':
102 - internal_tls_enabled
104 tripleo::profile::pacemaker::database::mysql_bundle::ca_file:
105 get_param: InternalTLSCAFile
108 # BEGIN DOCKER SETTINGS #
111 puppet_tags: file # set this even though file is the default
115 - - "['Mysql_datadir', 'Mysql_user', 'Mysql_database', 'Mysql_grant', 'Mysql_plugin'].each |String $val| { noop_resource($val) }"
116 - "exec {'wait-for-settle': command => '/bin/true' }"
117 - "include ::tripleo::profile::pacemaker::database::mysql_bundle"
118 config_image: {get_param: DockerMysqlConfigImage}
120 /var/lib/kolla/config_files/mysql.json:
121 command: /usr/sbin/pacemaker_remoted
123 - dest: /etc/libqb/force-filesystem-sockets
127 - source: "/var/lib/kolla/config_files/src/*"
130 preserve_properties: true
131 - source: "/var/lib/kolla/config_files/src-tls/*"
135 preserve_properties: true
137 - path: /etc/pki/tls/certs/mysql.crt
141 - path: /etc/pki/tls/private/mysql.key
147 mysql_data_ownership:
150 image: {get_param: DockerMysqlImage}
153 # Kolla does only non-recursive chown
154 command: ['chown', '-R', 'mysql:', '/var/lib/mysql']
156 - /var/lib/mysql:/var/lib/mysql
160 image: {get_param: DockerMysqlImage}
163 # Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
170 - - 'if [ -e /var/lib/mysql/mysql ]; then exit 0; fi'
171 - 'echo -e "\n[mysqld]\nwsrep_provider=none" >> /etc/my.cnf'
172 - 'sudo -u mysql -E kolla_start'
173 - 'mysqld_safe --skip-networking --wsrep-on=OFF &'
174 - 'timeout ${DB_MAX_TIMEOUT} /bin/bash -c ''until mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" ping 2>/dev/null; do sleep 1; done'''
175 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "CREATE USER ''clustercheck''@''localhost'' IDENTIFIED BY ''${DB_CLUSTERCHECK_PASSWORD}'';"'
176 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "GRANT PROCESS ON *.* TO ''clustercheck''@''localhost'' WITH GRANT OPTION;"'
177 - 'timeout ${DB_MAX_TIMEOUT} mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown'
178 volumes: &mysql_volumes
180 - {get_attr: [ContainersCommon, volumes]}
182 - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
183 - /var/lib/config-data/puppet-generated/mysql/:/var/lib/kolla/config_files/src:ro
184 - /var/lib/mysql:/var/lib/mysql
186 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
187 - KOLLA_BOOTSTRAP=True
188 # NOTE(mandre) skip wsrep cluster status check
189 - KOLLA_KUBERNETES=True
194 - - 'DB_CLUSTERCHECK_PASSWORD'
195 - {get_param: MysqlClustercheckPassword}
199 - - 'DB_ROOT_PASSWORD'
202 expression: $.data.passwords.where($ != '').first()
205 - {get_param: MysqlRootPassword}
206 - {get_param: [DefaultPasswords, mysql_root_password]}
217 "/usr/bin/docker tag 'MYSQL_IMAGE' 'MYSQL_IMAGE_PCMKLATEST'"
219 MYSQL_IMAGE: {get_param: DockerMysqlImage}
220 MYSQL_IMAGE_PCMKLATEST: *mysql_image_pcmklatest
221 image: {get_param: DockerMysqlImage}
223 - /etc/hosts:/etc/hosts:ro
224 - /etc/localtime:/etc/localtime:ro
225 - /dev/shm:/dev/shm:rw
226 - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
227 - /usr/bin:/usr/bin:ro
228 - /var/run/docker.sock:/var/run/docker.sock:rw
242 - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
243 - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
245 TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation,galera_ready,mysql_database,mysql_grant,mysql_user'
246 CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::database::mysql_bundle'
247 image: {get_param: DockerMysqlImage}
249 - /etc/hosts:/etc/hosts:ro
250 - /etc/localtime:/etc/localtime:ro
251 - /etc/puppet:/tmp/puppet-etc:ro
252 - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
253 - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
254 - /dev/shm:/dev/shm:rw
255 - /var/lib/mysql:/var/lib/mysql:rw
257 - name: create /var/lib/mysql
262 get_attr: [MysqlPuppetBase, role_data, metadata_settings]
264 - name: get bootstrap nodeid
266 command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
267 register: bootstrap_node
268 - name: set is_bootstrap_node fact
270 set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
271 - name: Check cluster resource status
279 - name: Disable the galera cluster resource
284 wait_for_resource: true
287 until: output.rc == 0
288 when: is_bootstrap_node and galera_res|succeeded
289 - name: Delete the stopped galera cluster resource.
294 wait_for_resource: true
297 until: output.rc == 0
298 when: is_bootstrap_node and galera_res|succeeded
299 - name: Disable mysql service
301 service: name=mariadb enabled=no
302 - name: Remove clustercheck service from xinetd
304 file: state=absent path=/etc/xinetd.d/galera-monitor
305 - name: Restart xinetd service after clustercheck removal
307 service: name=xinetd state=restarted