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