808f135338f81a07e1aed7b0b41a6c3784158161
[apex-tripleo-heat-templates.git] / puppet / services / database / mysql.yaml
1 heat_template_version: ocata
2
3 description: >
4   MySQL service deployment using puppet
5
6 parameters:
7   #Parameters not used EndpointMap
8   ServiceNetMap:
9     default: {}
10     description: Mapping of service_name -> network name. Typically set
11                  via parameter_defaults in the resource registry.  This
12                  mapping overrides those in ServiceNetMapDefaults.
13     type: json
14   DefaultPasswords:
15     default: {}
16     type: json
17   EndpointMap:
18     default: {}
19     description: Mapping of service endpoint -> protocol. Typically set
20                  via parameter_defaults in the resource registry.
21     type: json
22   MysqlMaxConnections:
23     description: Configures MySQL max_connections config setting
24     type: number
25     default: 4096
26   MysqlRootPassword:
27     type: string
28     hidden: true
29     default: ''
30   MysqlClustercheckPassword:
31     type: string
32     hidden: true
33   EnableGalera:
34     default: true
35     description: Whether to use Galera instead of regular MariaDB.
36     type: boolean
37   NovaPassword:
38     description: The password for the nova db account
39     type: string
40     hidden: true
41
42 resources:
43
44   MySQLTLS:
45     type: OS::TripleO::Services::MySQLTLS
46     properties:
47       ServiceNetMap: {get_param: ServiceNetMap}
48
49 outputs:
50   role_data:
51     description: Service MySQL using composable services.
52     value:
53       service_name: mysql
54       config_settings:
55         map_merge:
56           - get_attr: [MySQLTLS, role_data, config_settings]
57           -
58             # The Galera package should work in cluster and
59             # non-cluster modes based on the config file.
60             # We set the package name here explicitly so
61             # that it matches what we pre-install
62             # in tripleo-puppet-elements.
63             mysql::server::package_name: 'mariadb-galera-server'
64             mysql::server::manage_config_file: true
65             tripleo.mysql.firewall_rules:
66               '104 mysql galera':
67                 dport:
68                   - 873
69                   - 3306
70                   - 4444
71                   - 4567
72                   - 4568
73                   - 9200
74             mysql_max_connections: {get_param: MysqlMaxConnections}
75             mysql::server::root_password:
76               yaql:
77                 expression: $.data.passwords.where($ != '').first()
78                 data:
79                   passwords:
80                     - {get_param: MysqlRootPassword}
81                     - {get_param: [DefaultPasswords, mysql_root_password]}
82             mysql_clustercheck_password: {get_param: MysqlClustercheckPassword}
83             enable_galera: {get_param: EnableGalera}
84             # NOTE: bind IP is found in Heat replacing the network name with the
85             # local node IP for the given network; replacement examples
86             # (eg. for internal_api):
87             # internal_api -> IP
88             # internal_api_uri -> [IP]
89             # internal_api_subnet - > IP/CIDR
90             mysql_bind_host: {get_param: [ServiceNetMap, MysqlNetwork]}
91             tripleo::profile::base::database::mysql::bind_address:
92               str_replace:
93                 template:
94                   "%{hiera('fqdn_$NETWORK')}"
95                 params:
96                   $NETWORK: {get_param: [ServiceNetMap, MysqlNetwork]}
97             tripleo::profile::base::database::mysql::client_bind_address:
98               {get_param: [ServiceNetMap, MysqlNetwork]}
99       step_config: |
100         include ::tripleo::profile::base::database::mysql
101       metadata_settings:
102         get_attr: [MySQLTLS, role_data, metadata_settings]
103       upgrade_tasks:
104         - name: Check for galera root password
105           tags: step0
106           file: path=/root/.my.cnf state=file
107         - name: Stop service
108           tags: step2
109           service: name=mariadb state=stopped
110         - name: Start service
111           tags: step4
112           service: name=mariadb state=started
113         - name: Setup cell_v2 (create cell0 database)
114           tags: step4
115           mysql_db:
116             name: nova_cell0
117             state: present
118         - name: Setup cell_v2 (grant access to the nova DB user)
119           tags: step4
120           mysql_user:
121             str_replace:
122               template: "name=nova password=PASSWORD host=\"%\" priv=\"nova.*:ALL/nova_cell0.*:ALL,GRANT\" state=present"
123               params:
124                 PASSWORD: {get_param: NovaPassword}