1 heat_template_version: pike
4 MySQL service deployment using puppet
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.
33 description: Role name on which the service is applied
37 description: Parameters specific to the role
47 default: '/etc/ipa/ca.crt'
49 description: Specifies the default CA cert to use if TLS is used for
50 services in the internal network.
54 internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
59 type: ../../../puppet/services/database/mysql.yaml
61 EndpointMap: {get_param: EndpointMap}
62 ServiceData: {get_param: ServiceData}
63 ServiceNetMap: {get_param: ServiceNetMap}
64 DefaultPasswords: {get_param: DefaultPasswords}
65 RoleName: {get_param: RoleName}
66 RoleParameters: {get_param: RoleParameters}
70 description: Containerized service MySQL using composable services.
72 service_name: {get_attr: [MysqlPuppetBase, role_data, service_name]}
75 - {get_attr: [MysqlPuppetBase, role_data, config_settings]}
76 # Set PID file to what kolla mariadb bootstrap script expects
77 - tripleo::profile::base::database::mysql::mysql_server_options:
79 pid-file: /var/lib/mysql/mariadb.pid
81 pid-file: /var/lib/mysql/mariadb.pid
82 step_config: &step_config
85 - - "['Mysql_datadir', 'Mysql_user', 'Mysql_database', 'Mysql_grant', 'Mysql_plugin'].each |String $val| { noop_resource($val) }"
86 - {get_attr: [MysqlPuppetBase, role_data, step_config]}
87 # BEGIN DOCKER SETTINGS #
90 puppet_tags: file # set this even though file is the default
91 step_config: *step_config
92 config_image: &mysql_config_image {get_param: DockerMysqlConfigImage}
94 /var/lib/kolla/config_files/mysql.json:
95 command: /usr/bin/mysqld_safe
97 - source: "/var/lib/kolla/config_files/src/*"
100 preserve_properties: true
101 - source: "/var/lib/kolla/config_files/src-tls/*"
104 preserve_properties: true
107 - path: /var/lib/mysql
110 - path: /etc/pki/tls/certs/mysql.crt
113 - path: /etc/pki/tls/private/mysql.key
117 # Kolla_bootstrap runs before permissions set by kolla_config
120 image: &mysql_image {get_param: DockerMysqlImage}
124 - /var/log/containers/mysql:/var/log/mariadb
125 command: ['/bin/bash', '-c', 'chown -R mysql:mysql /var/log/mariadb']
133 # Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
140 - - 'if [ -e /var/lib/mysql/mysql ]; then exit 0; fi'
141 - 'echo -e "\n[mysqld]\nwsrep_provider=none" >> /etc/my.cnf'
142 - 'sudo -u mysql -E kolla_start'
143 - 'mysqld_safe --skip-networking --wsrep-on=OFF &'
144 - 'timeout ${DB_MAX_TIMEOUT} /bin/bash -c ''until mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" ping 2>/dev/null; do sleep 1; done'''
145 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "CREATE USER ''mysql''@''localhost'';"'
146 - 'mysql -uroot -p"${DB_ROOT_PASSWORD}" -e "REVOKE ALL PRIVILEGES, GRANT OPTION FROM ''mysql''@''localhost'';"'
147 - 'timeout ${DB_MAX_TIMEOUT} mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown'
148 volumes: &mysql_volumes
151 - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
152 - /var/lib/config-data/puppet-generated/mysql/:/var/lib/kolla/config_files/src:ro
153 - /etc/localtime:/etc/localtime:ro
154 - /etc/hosts:/etc/hosts:ro
155 - /var/lib/mysql:/var/lib/mysql
156 - /var/log/containers/mysql:/var/log/mariadb
158 - internal_tls_enabled
162 - - {get_param: InternalTLSCAFile}
163 - {get_param: InternalTLSCAFile}
165 - /etc/pki/tls/certs/mysql.crt:/var/lib/kolla/config_files/src-tls/etc/pki/tls/certs/mysql.crt:ro
166 - /etc/pki/tls/private/mysql.key:/var/lib/kolla/config_files/src-tls/etc/pki/tls/private/mysql.key:ro
169 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
170 - KOLLA_BOOTSTRAP=True
171 # NOTE(mandre) skip wsrep cluster status check
172 - KOLLA_KUBERNETES=True
177 - - 'DB_ROOT_PASSWORD'
180 expression: $.data.passwords.where($ != '').first()
183 - {get_param: MysqlRootPassword}
184 - {get_param: [DefaultPasswords, mysql_root_password]}
190 volumes: *mysql_volumes
192 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
194 # MySQL database initialization occurs only on single node
196 config_volume: 'mysql_init_tasks'
197 puppet_tags: 'mysql_database,mysql_grant,mysql_user'
198 step_config: 'include ::tripleo::profile::base::database::mysql'
199 config_image: *mysql_config_image
203 - /var/lib/mysql:/var/lib/mysql/:ro
204 - /var/log/containers/mysql:/var/log/mariadb
205 - /var/lib/config-data/mysql/root:/root:ro #provides .my.cnf
207 - internal_tls_enabled
211 - - {get_param: InternalTLSCAFile}
212 - {get_param: InternalTLSCAFile}
214 - /etc/pki/tls/certs/mysql.crt:/var/lib/kolla/config_files/src-tls/etc/pki/tls/certs/mysql.crt:ro
215 - /etc/pki/tls/private/mysql.key:/var/lib/kolla/config_files/src-tls/etc/pki/tls/private/mysql.key:ro
218 get_attr: [MysqlPuppetBase, role_data, metadata_settings]
220 - name: create persistent directories
225 - /var/log/containers/mysql
228 - name: Stop and disable mysql service
230 service: name=mariadb state=stopped enabled=no