Merge "Add BGPVPN composable service"
[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       puppet_config:
64         config_volume: mysql
65         puppet_tags: file # set this even though file is the default
66         step_config: *step_config
67         config_image: &mysql_image
68           list_join:
69             - '/'
70             - [ {get_param: DockerNamespace}, {get_param: DockerMysqlImage} ]
71       kolla_config:
72         /var/lib/kolla/config_files/mysql.json:
73           command: /usr/bin/mysqld_safe
74           config_files:
75           - dest: /etc/mysql/my.cnf
76             source: /var/lib/kolla/config_files/src/etc/my.cnf
77             owner: mysql
78             perm: '0644'
79           - dest: /etc/my.cnf.d/galera.cnf
80             source: /var/lib/kolla/config_files/src/etc/my.cnf.d/galera.cnf
81             owner: mysql
82             perm: '0644'
83       docker_config:
84         step_2:
85           mysql_bootstrap:
86             start_order: 0
87             detach: false
88             image: *mysql_image
89             net: host
90             volumes: &mysql_volumes
91               - /var/lib/kolla/config_files/mysql.json:/var/lib/kolla/config_files/config.json
92               - /var/lib/config-data/mysql/:/var/lib/kolla/config_files/src:ro
93               - /etc/localtime:/etc/localtime:ro
94               - /etc/hosts:/etc/hosts:ro
95               - mariadb:/var/lib/mysql/
96             environment:
97               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
98               - KOLLA_BOOTSTRAP=True
99               # NOTE(mandre) skip wsrep cluster status check
100               - KOLLA_KUBERNETES=True
101               - 
102                 list_join:
103                   - '='
104                   - - 'DB_ROOT_PASSWORD'
105                     -
106                       yaql:
107                         expression: $.data.passwords.where($ != '').first()
108                         data:
109                           passwords:
110                             - {get_param: MysqlRootPassword}
111                             - {get_param: [DefaultPasswords, mysql_root_password]}
112           mysql:
113             start_order: 1
114             image: *mysql_image
115             restart: always
116             net: host
117             volumes: *mysql_volumes
118             environment:
119               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
120       docker_puppet_tasks:
121         # MySQL database initialization occurs only on single node
122         step_2:
123           config_volume: 'mysql_init_tasks'
124           puppet_tags: 'mysql_database,mysql_grant,mysql_user'
125           step_config: 'include ::tripleo::profile::base::database::mysql'
126           config_image:
127             list_join:
128               - '/'
129               - [ {get_param: DockerNamespace}, {get_param: DockerMysqlImage} ]
130           volumes:
131             - "mariadb:/var/lib/mysql/:ro"
132             - "/var/lib/config-data/mysql/root:/root:ro" #provides .my.cnf
133       upgrade_tasks:
134         - name: Stop and disable mysql service
135           tags: step2
136           service: name=mariadb state=stopped enabled=no