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}
162 # Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
169 - - 'if [ -e /var/lib/mysql/mysql ]; then exit 0; fi'
171 - 'mysqld_safe --skip-networking --wsrep-on=OFF --wsrep-provider=none &'
172 - 'timeout ${DB_MAX_TIMEOUT} /bin/bash -c ''until mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" ping 2>/dev/null; do sleep 1; done'''
173 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "CREATE USER ''clustercheck''@''localhost'' IDENTIFIED BY ''${DB_CLUSTERCHECK_PASSWORD}'';"'
174 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "GRANT PROCESS ON *.* TO ''clustercheck''@''localhost'' WITH GRANT OPTION;"'
175 - 'timeout ${DB_MAX_TIMEOUT} mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown'
176 volumes: &mysql_volumes
178 - {get_attr: [ContainersCommon, volumes]}
180 - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
181 - /var/lib/config-data/puppet-generated/mysql/:/var/lib/kolla/config_files/src:ro
182 - /var/lib/mysql:/var/lib/mysql
184 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
185 - KOLLA_BOOTSTRAP=True
186 # NOTE(mandre) skip wsrep cluster status check
187 - KOLLA_KUBERNETES=True
192 - - 'DB_CLUSTERCHECK_PASSWORD'
193 - {get_param: MysqlClustercheckPassword}
197 - - 'DB_ROOT_PASSWORD'
200 expression: $.data.passwords.where($ != '').first()
203 - {get_param: MysqlRootPassword}
204 - {get_param: [DefaultPasswords, mysql_root_password]}
215 "/usr/bin/docker tag 'MYSQL_IMAGE' 'MYSQL_IMAGE_PCMKLATEST'"
217 MYSQL_IMAGE: {get_param: DockerMysqlImage}
218 MYSQL_IMAGE_PCMKLATEST: *mysql_image_pcmklatest
219 image: {get_param: DockerMysqlImage}
221 - /etc/hosts:/etc/hosts:ro
222 - /etc/localtime:/etc/localtime:ro
223 - /dev/shm:/dev/shm:rw
224 - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
225 - /usr/bin:/usr/bin:ro
226 - /var/run/docker.sock:/var/run/docker.sock:rw
240 - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
241 - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
243 TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation,galera_ready,mysql_database,mysql_grant,mysql_user'
244 CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::database::mysql_bundle'
245 image: {get_param: DockerMysqlImage}
247 - /etc/hosts:/etc/hosts:ro
248 - /etc/localtime:/etc/localtime:ro
249 - /etc/puppet:/tmp/puppet-etc:ro
250 - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
251 - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
252 - /dev/shm:/dev/shm:rw
253 - /var/lib/mysql:/var/lib/mysql:rw
255 - name: create /var/lib/mysql
260 get_attr: [MysqlPuppetBase, role_data, metadata_settings]
262 - name: get bootstrap nodeid
264 command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
265 register: bootstrap_node
266 - name: set is_bootstrap_node fact
268 set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
269 - name: Disable the galera cluster resource
274 wait_for_resource: true
275 when: is_bootstrap_node
276 - name: Delete the stopped galera cluster resource.
281 wait_for_resource: true
282 when: is_bootstrap_node
283 - name: Disable mysql service
285 service: name=mariadb enabled=no
286 - name: Remove clustercheck service from xinetd
288 file: state=absent path=/etc/xinetd.d/galera-monitor
289 - name: Restart xinetd service after clustercheck removal
291 service: name=xinetd state=restarted