Adds network/cidr mapping into a new service property
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / database / mysql.yaml
1 heat_template_version: pike
2
3 description: >
4   MySQL service deployment with pacemaker bundle
5
6 parameters:
7   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerMysqlImage:
12     description: image
13     default: 'centos-binary-mariadb:latest'
14     type: string
15   DockerMysqlConfigImage:
16     description: The container image to use for the mysql config_volume
17     default: 'centos-binary-mariadb:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceData:
25     default: {}
26     description: Dictionary packing service data
27     type: json
28   ServiceNetMap:
29     default: {}
30     description: Mapping of service_name -> network name. Typically set
31                  via parameter_defaults in the resource registry.  This
32                  mapping overrides those in ServiceNetMapDefaults.
33     type: json
34   DefaultPasswords:
35     default: {}
36     type: json
37   MysqlRootPassword:
38     type: string
39     hidden: true
40     default: ''
41   RoleName:
42     default: ''
43     description: Role name on which the service is applied
44     type: string
45   RoleParameters:
46     default: {}
47     description: Parameters specific to the role
48     type: json
49
50 resources:
51
52   ContainersCommon:
53     type: ../../containers-common.yaml
54
55   MysqlPuppetBase:
56     type: ../../../../puppet/services/pacemaker/database/mysql.yaml
57     properties:
58       EndpointMap: {get_param: EndpointMap}
59       ServiceData: {get_param: ServiceData}
60       ServiceNetMap: {get_param: ServiceNetMap}
61       DefaultPasswords: {get_param: DefaultPasswords}
62       RoleName: {get_param: RoleName}
63       RoleParameters: {get_param: RoleParameters}
64
65 outputs:
66   role_data:
67     description: Containerized service MySQL using composable services.
68     value:
69       service_name: {get_attr: [MysqlPuppetBase, role_data, service_name]}
70       config_settings:
71         map_merge:
72           - {get_attr: [MysqlPuppetBase, role_data, config_settings]}
73           - tripleo::profile::pacemaker::database::mysql_bundle::mysql_docker_image: &mysql_image
74               list_join:
75                 - '/'
76                 - - {get_param: DockerNamespace}
77                   - {get_param: DockerMysqlImage}
78       step_config: ""
79       # BEGIN DOCKER SETTINGS #
80       puppet_config:
81         config_volume: mysql
82         puppet_tags: file # set this even though file is the default
83         step_config:
84           list_join:
85             - "\n"
86             - - "['Mysql_datadir', 'Mysql_user', 'Mysql_database', 'Mysql_grant', 'Mysql_plugin'].each |String $val| { noop_resource($val) }"
87               - "exec {'wait-for-settle': command => '/bin/true' }"
88               - "include ::tripleo::profile::pacemaker::database::mysql_bundle"
89         config_image:
90           list_join:
91             - '/'
92             - [ {get_param: DockerNamespace}, {get_param: DockerMysqlConfigImage} ]
93       kolla_config:
94         /var/lib/kolla/config_files/mysql.json:
95           command: /usr/sbin/pacemaker_remoted
96           config_files:
97             - dest: /etc/libqb/force-filesystem-sockets
98               source: /dev/null
99               owner: root
100               perm: '0644'
101             - source: "/var/lib/kolla/config_files/src/*"
102               dest: "/"
103               merge: true
104               preserve_properties: true
105       docker_config:
106         step_1:
107           mysql_data_ownership:
108             start_order: 0
109             detach: false
110             image: *mysql_image
111             net: host
112             user: root
113             # Kolla does only non-recursive chown
114             command: ['chown', '-R', 'mysql:', '/var/lib/mysql']
115             volumes:
116               - /var/lib/mysql:/var/lib/mysql
117           mysql_bootstrap:
118             start_order: 1
119             detach: false
120             image: *mysql_image
121             net: host
122             # Kolla bootstraps aren't idempotent, explicitly checking if bootstrap was done
123             command: ['bash', '-c', 'test -e /var/lib/mysql/mysql || kolla_start']
124             volumes: &mysql_volumes
125               list_concat:
126                 - {get_attr: [ContainersCommon, volumes]}
127                 -
128                   - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
129                   - /var/lib/config-data/puppet-generated/mysql/:/var/lib/kolla/config_files/src:ro
130                   - /var/lib/mysql:/var/lib/mysql
131             environment:
132               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
133               - KOLLA_BOOTSTRAP=True
134               # NOTE(mandre) skip wsrep cluster status check
135               - KOLLA_KUBERNETES=True
136               -
137                 list_join:
138                   - '='
139                   - - 'DB_ROOT_PASSWORD'
140                     -
141                       yaql:
142                         expression: $.data.passwords.where($ != '').first()
143                         data:
144                           passwords:
145                             - {get_param: MysqlRootPassword}
146                             - {get_param: [DefaultPasswords, mysql_root_password]}
147         step_2:
148           mysql_init_bundle:
149             start_order: 1
150             detach: false
151             net: host
152             user: root
153             command:
154               - '/bin/bash'
155               - '-c'
156               - str_replace:
157                   template:
158                     list_join:
159                       - '; '
160                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
161                         - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
162                   params:
163                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation,galera_ready,mysql_database,mysql_grant,mysql_user'
164                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::database::mysql_bundle'
165             image: *mysql_image
166             volumes:
167               - /etc/hosts:/etc/hosts:ro
168               - /etc/localtime:/etc/localtime:ro
169               - /etc/puppet:/tmp/puppet-etc:ro
170               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
171               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
172               - /dev/shm:/dev/shm:rw
173               - /var/lib/mysql:/var/lib/mysql:rw
174       host_prep_tasks:
175         - name: create /var/lib/mysql
176           file:
177             path: /var/lib/mysql
178             state: directory
179       upgrade_tasks:
180         - name: Stop and disable mysql service
181           tags: step2
182           service: name=mariadb state=stopped enabled=no