7078b60fc186685d706e136decf7b98aedd051bd
[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   MysqlIncreaseFileLimit:
27     description: Flag to increase MySQL open-files-limit to 16384
28     type: boolean
29     default: true
30   MysqlRootPassword:
31     type: string
32     hidden: true
33     default: ''
34   MysqlClustercheckPassword:
35     type: string
36     hidden: true
37   EnableGalera:
38     default: true
39     description: Whether to use Galera instead of regular MariaDB.
40     type: boolean
41   NovaPassword:
42     description: The password for the nova db account
43     type: string
44     hidden: true
45
46 resources:
47
48   MySQLTLS:
49     type: OS::TripleO::Services::MySQLTLS
50     properties:
51       ServiceNetMap: {get_param: ServiceNetMap}
52
53 outputs:
54   role_data:
55     description: Service MySQL using composable services.
56     value:
57       service_name: mysql
58       config_settings:
59         map_merge:
60           - get_attr: [MySQLTLS, role_data, config_settings]
61           -
62             # The Galera package should work in cluster and
63             # non-cluster modes based on the config file.
64             # We set the package name here explicitly so
65             # that it matches what we pre-install
66             # in tripleo-puppet-elements.
67             mysql::server::package_name: 'mariadb-galera-server'
68             mysql::server::manage_config_file: true
69             tripleo.mysql.firewall_rules:
70               '104 mysql galera':
71                 dport:
72                   - 873
73                   - 3306
74                   - 4444
75                   - 4567
76                   - 4568
77                   - 9200
78             mysql_max_connections: {get_param: MysqlMaxConnections}
79             mysql::server::root_password:
80               yaql:
81                 expression: $.data.passwords.where($ != '').first()
82                 data:
83                   passwords:
84                     - {get_param: MysqlRootPassword}
85                     - {get_param: [DefaultPasswords, mysql_root_password]}
86             mysql_clustercheck_password: {get_param: MysqlClustercheckPassword}
87             enable_galera: {get_param: EnableGalera}
88             # NOTE: bind IP is found in Heat replacing the network name with the
89             # local node IP for the given network; replacement examples
90             # (eg. for internal_api):
91             # internal_api -> IP
92             # internal_api_uri -> [IP]
93             # internal_api_subnet - > IP/CIDR
94             mysql_bind_host: {get_param: [ServiceNetMap, MysqlNetwork]}
95             tripleo::profile::base::database::mysql::bind_address:
96               str_replace:
97                 template:
98                   "%{hiera('fqdn_$NETWORK')}"
99                 params:
100                   $NETWORK: {get_param: [ServiceNetMap, MysqlNetwork]}
101             tripleo::profile::base::database::mysql::client_bind_address:
102               {get_param: [ServiceNetMap, MysqlNetwork]}
103             tripleo::profile::base::database::mysql::generate_dropin_file_limit:
104               {get_param: MysqlIncreaseFileLimit}
105       step_config: |
106         include ::tripleo::profile::base::database::mysql
107       metadata_settings:
108         get_attr: [MySQLTLS, role_data, metadata_settings]
109       upgrade_tasks:
110         - name: Check for galera root password
111           tags: step0
112           file: path=/root/.my.cnf state=file
113         - name: Stop service
114           tags: step2
115           service: name=mariadb state=stopped
116         - name: Start service
117           tags: step4
118           service: name=mariadb state=started
119         - name: Setup cell_v2 (create cell0 database)
120           tags: step4
121           mysql_db:
122             name: nova_cell0
123             state: present
124         - name: Setup cell_v2 (grant access to the nova DB user)
125           tags: step4
126           mysql_user:
127             str_replace:
128               template: "name=nova password=PASSWORD host=\"%\" priv=\"nova.*:ALL/nova_cell0.*:ALL,GRANT\" state=present"
129               params:
130                 PASSWORD: {get_param: NovaPassword}