Merge "Add detach to docker-toool"
[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   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerMongodbImage:
12     description: image
13     default: 'centos-binary-mongodb:latest'
14     type: string
15   DockerMongodbConfigImage:
16     description: The container image to use for the mongodb config_volume
17     default: 'centos-binary-mongodb:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceNetMap:
25     default: {}
26     description: Mapping of service_name -> network name. Typically set
27                  via parameter_defaults in the resource registry.  This
28                  mapping overrides those in ServiceNetMapDefaults.
29     type: json
30   DefaultPasswords:
31     default: {}
32     type: json
33   RoleName:
34     default: ''
35     description: Role name on which the service is applied
36     type: string
37   RoleParameters:
38     default: {}
39     description: Parameters specific to the role
40     type: json
41
42 resources:
43
44   MongodbPuppetBase:
45     type: ../../../puppet/services/database/mongodb.yaml
46     properties:
47       EndpointMap: {get_param: EndpointMap}
48       ServiceNetMap: {get_param: ServiceNetMap}
49       DefaultPasswords: {get_param: DefaultPasswords}
50       RoleName: {get_param: RoleName}
51       RoleParameters: {get_param: RoleParameters}
52
53 outputs:
54   role_data:
55     description: Containerized service Mongodb using composable services.
56     value:
57       service_name: {get_attr: [MongodbPuppetBase, role_data, service_name]}
58       config_settings:
59         map_merge:
60           - get_attr: [MongodbPuppetBase, role_data, config_settings]
61           - mongodb::server::fork: false
62       step_config: &step_config
63         list_join:
64           - "\n"
65           - - "['Mongodb_database', 'Mongodb_user', 'Mongodb_replset'].each |String $val| { noop_resource($val) }"
66             - {get_attr: [MongodbPuppetBase, role_data, step_config]}
67       # BEGIN DOCKER SETTINGS #
68       puppet_config:
69         config_volume: mongodb
70         puppet_tags: file # set this even though file is the default
71         step_config: *step_config
72         config_image: &mongodb_config_image
73           list_join:
74             - '/'
75             - [ {get_param: DockerNamespace}, {get_param: DockerMongodbConfigImage} ]
76       kolla_config:
77         /var/lib/kolla/config_files/mongodb.json:
78           command: /usr/bin/mongod --unixSocketPrefix=/var/run/mongodb --config /etc/mongod.conf run
79           permissions:
80             - path: /var/lib/mongodb
81               owner: mongodb:mongodb
82               recurse: true
83             - path: /var/log/mongodb
84               owner: mongodb:mongodb
85               recurse: true
86       docker_config:
87         step_2:
88           mongodb:
89             image:
90               list_join:
91                 - '/'
92                 - [ {get_param: DockerNamespace}, {get_param: DockerMongodbImage} ]
93             net: host
94             privileged: false
95             volumes: &mongodb_volumes
96               - /var/lib/kolla/config_files/mongodb.json:/var/lib/kolla/config_files/config.json
97               - /var/lib/config-data/mongodb/etc/mongod.conf:/etc/mongod.conf:ro
98               - /var/lib/config-data/mongodb/etc/mongos.conf:/etc/mongos.conf:ro
99               - /etc/localtime:/etc/localtime:ro
100               - /var/log/containers/mongodb:/var/log/mongodb
101               - /var/lib/mongodb:/var/lib/mongodb
102             environment:
103               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
104       docker_puppet_tasks:
105         # MySQL database initialization occurs only on single node
106         step_2:
107           config_volume: 'mongodb_init_tasks'
108           puppet_tags: 'mongodb_database,mongodb_user,mongodb_replset'
109           step_config: 'include ::tripleo::profile::base::database::mongodb'
110           config_image: *mongodb_config_image
111           volumes:
112             - /var/lib/mongodb:/var/lib/mongodb
113             - /var/log/containers/mongodb:/var/log/mongodb
114       host_prep_tasks:
115         - name: create persistent directories
116           file:
117             path: "{{ item }}"
118             state: directory
119           with_items:
120             - /var/log/containers/mongodb
121             - /var/lib/mongodb
122       upgrade_tasks:
123         - name: Stop and disable mongodb service
124           tags: step2
125           service: name=mongod state=stopped enabled=no