Merge "Keystone token flush cron job should log to a file"
[apex-tripleo-heat-templates.git] / docker / services / database / mysql.yaml
1 heat_template_version: ocata
2
3 description: >
4   MySQL service deployment using puppet
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   EndpointMap:
16     default: {}
17     description: Mapping of service endpoint -> protocol. Typically set
18                  via parameter_defaults in the resource registry.
19     type: json
20   ServiceNetMap:
21     default: {}
22     description: Mapping of service_name -> network name. Typically set
23                  via parameter_defaults in the resource registry.  This
24                  mapping overrides those in ServiceNetMapDefaults.
25     type: json
26   DefaultPasswords:
27     default: {}
28     type: json
29   MysqlRootPassword:
30     type: string
31     hidden: true
32     default: ''
33
34 resources:
35
36   MysqlPuppetBase:
37     type: ../../../puppet/services/database/mysql.yaml
38     properties:
39       EndpointMap: {get_param: EndpointMap}
40       ServiceNetMap: {get_param: ServiceNetMap}
41       DefaultPasswords: {get_param: DefaultPasswords}
42
43 outputs:
44   role_data:
45     description: Containerized service MySQL using composable services.
46     value:
47       service_name: {get_attr: [MysqlPuppetBase, role_data, service_name]}
48       config_settings:
49         map_merge:
50           - {get_attr: [MysqlPuppetBase, role_data, config_settings]}
51           # Set PID file to what kolla mariadb bootstrap script expects
52           - tripleo::profile::base::database::mysql::mysql_server_options:
53               mysqld:
54                 pid-file: /var/lib/mysql/mariadb.pid
55               mysqld_safe:
56                 pid-file: /var/lib/mysql/mariadb.pid
57       step_config: &step_config
58         list_join:
59           - "\n"
60           - - "['Mysql_datadir', 'Mysql_user', 'Mysql_database', 'Mysql_grant', 'Mysql_plugin'].each |String $val| { noop_resource($val) }"
61             - {get_attr: [MysqlPuppetBase, role_data, step_config]}
62       # BEGIN DOCKER SETTINGS #
63       docker_image: &mysql_image
64         list_join:
65           - '/'
66           - [ {get_param: DockerNamespace}, {get_param: DockerMysqlImage} ]
67       puppet_config:
68         config_volume: mysql
69         puppet_tags: file # set this even though file is the default
70         step_config: *step_config
71         config_image: *mysql_image
72       kolla_config:
73         /var/lib/kolla/config_files/mysql.json:
74           command: /usr/bin/mysqld_safe
75           config_files:
76           - dest: /etc/mysql/my.cnf
77             source: /var/lib/kolla/config_files/src/etc/my.cnf
78             owner: mysql
79             perm: '0644'
80           - dest: /etc/my.cnf.d/galera.cnf
81             source: /var/lib/kolla/config_files/src/etc/my.cnf.d/galera.cnf
82             owner: mysql
83             perm: '0644'
84       docker_config:
85         step_2:
86           mysql_bootstrap:
87             start_order: 0
88             detach: false
89             image: *mysql_image
90             net: host
91             volumes: &mysql_volumes
92               - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
93               - /var/lib/config-data/mysql/:/var/lib/kolla/config_files/src:ro
94               - /etc/localtime:/etc/localtime:ro
95               - /etc/hosts:/etc/hosts:ro
96               - mariadb:/var/lib/mysql/
97             environment:
98               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
99               - KOLLA_BOOTSTRAP=True
100               # NOTE(mandre) skip wsrep cluster status check
101               - KOLLA_KUBERNETES=True
102               - 
103                 list_join:
104                   - '='
105                   - - 'DB_ROOT_PASSWORD'
106                     -
107                       yaql:
108                         expression: $.data.passwords.where($ != '').first()
109                         data:
110                           passwords:
111                             - {get_param: MysqlRootPassword}
112                             - {get_param: [DefaultPasswords, mysql_root_password]}
113           mysql:
114             start_order: 1
115             image: *mysql_image
116             restart: always
117             net: host
118             volumes: *mysql_volumes
119             environment:
120               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
121       docker_puppet_tasks:
122         # MySQL database initialization occurs only on single node
123         step_2:
124           config_volume: 'mysql_init_tasks'
125           puppet_tags: 'mysql_database,mysql_grant,mysql_user'
126           step_config: 'include ::tripleo::profile::base::database::mysql'
127           config_image:
128             list_join:
129               - '/'
130               - [ {get_param: DockerNamespace}, {get_param: DockerMysqlImage} ]
131           volumes:
132             - "mariadb:/var/lib/mysql/:ro"
133             - "/var/lib/config-data/mysql/root:/root:ro" #provides .my.cnf
134       upgrade_tasks:
135         - name: Stop and disable mysql service
136           tags: step2
137           service: name=mariadb state=stopped enabled=no