Containarise Barbican API
[apex-tripleo-heat-templates.git] / docker / services / database / mongodb.yaml
1 heat_template_version: pike
2
3 description: >
4   MongoDB service deployment using puppet and docker
5
6 parameters:
7   DockerMongodbImage:
8     description: image
9     type: string
10   DockerMongodbConfigImage:
11     description: The container image to use for the mongodb config_volume
12     type: string
13   EndpointMap:
14     default: {}
15     description: Mapping of service endpoint -> protocol. Typically set
16                  via parameter_defaults in the resource registry.
17     type: json
18   ServiceData:
19     default: {}
20     description: Dictionary packing service data
21     type: json
22   ServiceNetMap:
23     default: {}
24     description: Mapping of service_name -> network name. Typically set
25                  via parameter_defaults in the resource registry.  This
26                  mapping overrides those in ServiceNetMapDefaults.
27     type: json
28   DefaultPasswords:
29     default: {}
30     type: json
31   RoleName:
32     default: ''
33     description: Role name on which the service is applied
34     type: string
35   RoleParameters:
36     default: {}
37     description: Parameters specific to the role
38     type: json
39   EnableInternalTLS:
40     type: boolean
41     default: false
42   InternalTLSCAFile:
43     default: '/etc/ipa/ca.crt'
44     type: string
45     description: Specifies the default CA cert to use if TLS is used for
46                  services in the internal network.
47
48 conditions:
49
50   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
51
52 resources:
53
54   MongodbPuppetBase:
55     type: ../../../puppet/services/database/mongodb.yaml
56     properties:
57       EndpointMap: {get_param: EndpointMap}
58       ServiceData: {get_param: ServiceData}
59       ServiceNetMap: {get_param: ServiceNetMap}
60       DefaultPasswords: {get_param: DefaultPasswords}
61       RoleName: {get_param: RoleName}
62       RoleParameters: {get_param: RoleParameters}
63
64 outputs:
65   role_data:
66     description: Containerized service Mongodb using composable services.
67     value:
68       service_name: {get_attr: [MongodbPuppetBase, role_data, service_name]}
69       config_settings:
70         map_merge:
71           - get_attr: [MongodbPuppetBase, role_data, config_settings]
72           - mongodb::server::fork: false
73       step_config: &step_config
74         list_join:
75           - "\n"
76           - - "['Mongodb_database', 'Mongodb_user', 'Mongodb_replset'].each |String $val| { noop_resource($val) }"
77             - {get_attr: [MongodbPuppetBase, role_data, step_config]}
78       # BEGIN DOCKER SETTINGS #
79       puppet_config:
80         config_volume: mongodb
81         puppet_tags: file # set this even though file is the default
82         step_config: *step_config
83         config_image: &mongodb_config_image {get_param: DockerMongodbConfigImage}
84       kolla_config:
85         /var/lib/kolla/config_files/mongodb.json:
86           command: /usr/bin/mongod --unixSocketPrefix=/var/run/mongodb --config /etc/mongod.conf run
87           config_files:
88             - source: "/var/lib/kolla/config_files/src/*"
89               dest: "/"
90               merge: true
91               preserve_properties: true
92             - source: "/var/lib/kolla/config_files/src-tls/*"
93               dest: "/"
94               merge: true
95               preserve_properties: true
96           permissions:
97             - path: /var/lib/mongodb
98               owner: mongodb:mongodb
99               recurse: true
100             - path: /var/log/mongodb
101               owner: mongodb:mongodb
102               recurse: true
103             - path: /etc/pki/tls/certs/mongodb.pem
104               owner: mongodb:mongodb
105       docker_config:
106         step_2:
107           mongodb:
108             image: {get_param: DockerMongodbImage}
109             net: host
110             privileged: false
111             volumes: &mongodb_volumes
112               list_concat:
113                 - - /var/lib/kolla/config_files/mongodb.json:/var/lib/kolla/config_files/config.json
114                   - /var/lib/config-data/puppet-generated/mongodb/:/var/lib/kolla/config_files/src:ro
115                   - /etc/localtime:/etc/localtime:ro
116                   - /var/log/containers/mongodb:/var/log/mongodb
117                   - /var/lib/mongodb:/var/lib/mongodb
118                 - if:
119                   - internal_tls_enabled
120                   - - list_join:
121                       - ':'
122                       - - {get_param: InternalTLSCAFile}
123                         - {get_param: InternalTLSCAFile}
124                         - 'ro'
125                     - /etc/pki/tls/certs/mongodb.pem:/var/lib/kolla/config_files/src-tls/etc/pki/tls/certs/mongodb.pem:ro
126                   - null
127             environment:
128               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
129       docker_puppet_tasks:
130         # MySQL database initialization occurs only on single node
131         step_2:
132           config_volume: 'mongodb_init_tasks'
133           puppet_tags: 'mongodb_database,mongodb_user,mongodb_replset'
134           step_config: 'include ::tripleo::profile::base::database::mongodb'
135           config_image: *mongodb_config_image
136           volumes:
137             list_concat:
138               - - /var/lib/mongodb:/var/lib/mongodb
139                 - /var/log/containers/mongodb:/var/log/mongodb
140               - if:
141                 - internal_tls_enabled
142                 - - list_join:
143                     - ':'
144                     - - {get_param: InternalTLSCAFile}
145                       - {get_param: InternalTLSCAFile}
146                       - 'ro'
147                   - /etc/pki/tls/certs/mongodb.pem:/var/lib/kolla/config_files/src-tls/etc/pki/tls/certs/mongodb.pem:ro
148                 - null
149       host_prep_tasks:
150         - name: create persistent directories
151           file:
152             path: "{{ item }}"
153             state: directory
154           with_items:
155             - /var/log/containers/mongodb
156             - /var/lib/mongodb
157       metadata_settings:
158         get_attr: [MongodbPuppetBase, role_data, metadata_settings]
159       upgrade_tasks:
160         - name: Stop and disable mongodb service
161           tags: step2
162           service: name=mongod state=stopped enabled=no