dcead0f7afd41410a8e1aa8cba69f9614644b347
[apex-tripleo-heat-templates.git] / puppet / services / database / mongodb.yaml
1 heat_template_version: pike
2
3 description: >
4   MongoDb service deployment using puppet
5
6 parameters:
7   #Parameters not used EndpointMap
8   ServiceData:
9     default: {}
10     description: Dictionary packing service data
11     type: json
12   ServiceNetMap:
13     default: {}
14     description: Mapping of service_name -> network name. Typically set
15                  via parameter_defaults in the resource registry.  This
16                  mapping overrides those in ServiceNetMapDefaults.
17     type: json
18   DefaultPasswords:
19     default: {}
20     type: json
21   RoleName:
22     default: ''
23     description: Role name on which the service is applied
24     type: string
25   RoleParameters:
26     default: {}
27     description: Parameters specific to the role
28     type: json
29   EndpointMap:
30     default: {}
31     description: Mapping of service endpoint -> protocol. Typically set
32                  via parameter_defaults in the resource registry.
33     type: json
34   MongodbMemoryLimit:
35     default: '20G'
36     description: Limit the amount of memory mongodb uses with systemd.
37     type: string
38   MongoDbLoggingSource:
39     type: json
40     description: Fluentd logging configuration for mongodb.
41     default:
42       tag: database.mongodb
43       path: /var/log/mongodb/mongodb.log
44       format: >-
45         /(?<time>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+\+\d{4})
46         (?<message>.*)$/
47   EnableInternalTLS:
48     type: boolean
49     default: false
50   InternalTLSCAFile:
51     default: '/etc/ipa/ca.crt'
52     type: string
53     description: Specifies the default CA cert to use if TLS is used for
54                  services in the internal network.
55
56 conditions:
57
58   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
59
60 resources:
61   MongoDbBase:
62     type: ./mongodb-base.yaml
63     properties:
64       ServiceData: {get_param: ServiceData}
65       ServiceNetMap: {get_param: ServiceNetMap}
66       DefaultPasswords: {get_param: DefaultPasswords}
67       EndpointMap: {get_param: EndpointMap}
68       RoleName: {get_param: RoleName}
69       RoleParameters: {get_param: RoleParameters}
70
71 outputs:
72   role_data:
73     description: Service mongodb using composable services.
74     value:
75       service_name: mongodb
76       logging_groups:
77         - mongodb
78       logging_source: {get_param: MongoDbLoggingSource}
79       config_settings:
80         map_merge:
81           - get_attr: [MongoDbBase, role_data, config_settings]
82           - tripleo::profile::base::database::mongodb::mongodb_replset: {get_attr: [MongoDbBase, aux_parameters, rplset_name]}
83             tripleo::profile::base::database::mongodb::memory_limit: {get_param: MongodbMemoryLimit}
84             mongodb::server::service_manage: True
85             tripleo.mongodb.firewall_rules:
86               '101 mongodb_config':
87                 dport: 27019
88               '102 mongodb_sharding':
89                 dport: 27018
90               '103 mongod':
91                 dport: 27017
92             # NOTE: bind IP is found in Heat replacing the network name with the
93             # local node IP for the given network; replacement examples
94             # (eg. for internal_api):
95             # internal_api -> IP
96             # internal_api_uri -> [IP]
97             # internal_api_subnet - > IP/CIDR
98             mongodb::server::bind_ip: {get_param: [ServiceNetMap, MongodbNetwork]}
99           -
100             if:
101               - internal_tls_enabled
102               -
103                 generate_service_certificates: true
104                 mongodb::server::ssl: true
105                 mongodb::server::ssl_key: '/etc/pki/tls/certs/mongodb.pem'
106                 mongodb::server::ssl_ca: {get_param: InternalTLSCAFile}
107                 mongodb_certificate_specs:
108                   service_pem: '/etc/pki/tls/certs/mongodb.pem'
109                   service_certificate: '/etc/pki/tls/certs/mongodb.crt'
110                   service_key: '/etc/pki/tls/private/mongodb.key'
111                   hostname:
112                     str_replace:
113                       template: "%{hiera('fqdn_NETWORK')}"
114                       params:
115                         NETWORK: {get_param: [ServiceNetMap, MongodbNetwork]}
116                   principal:
117                     str_replace:
118                       template: "mongodb/%{hiera('fqdn_NETWORK')}"
119                       params:
120                         NETWORK: {get_param: [ServiceNetMap, MongodbNetwork]}
121               - {}
122       step_config: |
123         include ::tripleo::profile::base::database::mongodb
124       upgrade_tasks:
125         - name: Stop mongodb service
126           tags: step2
127           service: name=mongod state=stopped
128         - name: Start mongodb service
129           tags: step4
130           service: name=mongod state=started
131       metadata_settings:
132         if:
133           - internal_tls_enabled
134           -
135             - service: mongodb
136               network: {get_param: [ServiceNetMap, MongodbNetwork]}
137               type: node
138           - null