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