Merge "Handles {controller,NovaCompute}ExtraConfig deprecation in ovecloud.j2"
[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
40 resources:
41
42   MongodbPuppetBase:
43     type: ../../../puppet/services/database/mongodb.yaml
44     properties:
45       EndpointMap: {get_param: EndpointMap}
46       ServiceData: {get_param: ServiceData}
47       ServiceNetMap: {get_param: ServiceNetMap}
48       DefaultPasswords: {get_param: DefaultPasswords}
49       RoleName: {get_param: RoleName}
50       RoleParameters: {get_param: RoleParameters}
51
52 outputs:
53   role_data:
54     description: Containerized service Mongodb using composable services.
55     value:
56       service_name: {get_attr: [MongodbPuppetBase, role_data, service_name]}
57       config_settings:
58         map_merge:
59           - get_attr: [MongodbPuppetBase, role_data, config_settings]
60           - mongodb::server::fork: false
61       step_config: &step_config
62         list_join:
63           - "\n"
64           - - "['Mongodb_database', 'Mongodb_user', 'Mongodb_replset'].each |String $val| { noop_resource($val) }"
65             - {get_attr: [MongodbPuppetBase, role_data, step_config]}
66       # BEGIN DOCKER SETTINGS #
67       puppet_config:
68         config_volume: mongodb
69         puppet_tags: file # set this even though file is the default
70         step_config: *step_config
71         config_image: &mongodb_config_image {get_param: DockerMongodbConfigImage}
72       kolla_config:
73         /var/lib/kolla/config_files/mongodb.json:
74           command: /usr/bin/mongod --unixSocketPrefix=/var/run/mongodb --config /etc/mongod.conf run
75           config_files:
76             - source: "/var/lib/kolla/config_files/src/*"
77               dest: "/"
78               merge: true
79               preserve_properties: true
80           permissions:
81             - path: /var/lib/mongodb
82               owner: mongodb:mongodb
83               recurse: true
84             - path: /var/log/mongodb
85               owner: mongodb:mongodb
86               recurse: true
87       docker_config:
88         step_2:
89           mongodb:
90             image: {get_param: DockerMongodbImage}
91             net: host
92             privileged: false
93             volumes: &mongodb_volumes
94               - /var/lib/kolla/config_files/mongodb.json:/var/lib/kolla/config_files/config.json
95               - /var/lib/config-data/puppet-generated/mongodb/:/var/lib/kolla/config_files/src:ro
96               - /etc/localtime:/etc/localtime:ro
97               - /var/log/containers/mongodb:/var/log/mongodb
98               - /var/lib/mongodb:/var/lib/mongodb
99             environment:
100               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
101       docker_puppet_tasks:
102         # MySQL database initialization occurs only on single node
103         step_2:
104           config_volume: 'mongodb_init_tasks'
105           puppet_tags: 'mongodb_database,mongodb_user,mongodb_replset'
106           step_config: 'include ::tripleo::profile::base::database::mongodb'
107           config_image: *mongodb_config_image
108           volumes:
109             - /var/lib/mongodb:/var/lib/mongodb
110             - /var/log/containers/mongodb:/var/log/mongodb
111       host_prep_tasks:
112         - name: create persistent directories
113           file:
114             path: "{{ item }}"
115             state: directory
116           with_items:
117             - /var/log/containers/mongodb
118             - /var/lib/mongodb
119       upgrade_tasks:
120         - name: Stop and disable mongodb service
121           tags: step2
122           service: name=mongod state=stopped enabled=no