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