Merge "Modify PreNetworkConfig config inline with role-specific parameters"
[apex-tripleo-heat-templates.git] / docker / services / cinder-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Cinder API service
5
6 parameters:
7   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerCinderApiImage:
12     description: image
13     default: 'centos-binary-cinder-api:latest'
14     type: string
15   # we configure all cinder services in the same cinder base container
16   DockerCinderConfigImage:
17     description: image
18     default: 'centos-binary-cinder-api:latest'
19     type: string
20   EndpointMap:
21     default: {}
22     description: Mapping of service endpoint -> protocol. Typically set
23                  via parameter_defaults in the resource registry.
24     type: json
25   ServiceNetMap:
26     default: {}
27     description: Mapping of service_name -> network name. Typically set
28                  via parameter_defaults in the resource registry.  This
29                  mapping overrides those in ServiceNetMapDefaults.
30     type: json
31   DefaultPasswords:
32     default: {}
33     type: json
34   RoleName:
35     default: ''
36     description: Role name on which the service is applied
37     type: string
38   RoleParameters:
39     default: {}
40     description: Parameters specific to the role
41     type: json
42   EnableInternalTLS:
43     type: boolean
44     default: false
45
46 conditions:
47
48   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
49
50 resources:
51
52   ContainersCommon:
53     type: ./containers-common.yaml
54
55   CinderBase:
56     type: ../../puppet/services/cinder-api.yaml
57     properties:
58       EndpointMap: {get_param: EndpointMap}
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: Role data for the Cinder API role.
67     value:
68       service_name: {get_attr: [CinderBase, role_data, service_name]}
69       config_settings: {get_attr: [CinderBase, role_data, config_settings]}
70       step_config: &step_config
71         get_attr: [CinderBase, role_data, step_config]
72       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
73       # BEGIN DOCKER SETTINGS
74       puppet_config:
75         config_volume: cinder
76         puppet_tags: cinder_config,file,concat,file_line
77         step_config: *step_config
78         config_image:
79           list_join:
80             - '/'
81             - [ {get_param: DockerNamespace}, {get_param: DockerCinderConfigImage} ]
82       kolla_config:
83         /var/lib/kolla/config_files/cinder_api.json:
84           command: /usr/sbin/httpd -DFOREGROUND
85           permissions:
86             - path: /var/log/cinder
87               owner: cinder:cinder
88               recurse: true
89       docker_config:
90         step_2:
91           cinder_api_init_logs:
92             image: &cinder_api_image
93               list_join:
94                 - '/'
95                 - [ {get_param: DockerNamespace}, {get_param: DockerCinderApiImage} ]
96             privileged: false
97             user: root
98             volumes:
99               - /var/log/containers/cinder:/var/log/cinder
100             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
101         step_3:
102           cinder_api_db_sync:
103             image: *cinder_api_image
104             net: host
105             privileged: false
106             detach: false
107             user: root
108             volumes:
109               list_concat:
110                 - {get_attr: [ContainersCommon, volumes]}
111                 -
112                   - /var/lib/config-data/cinder/etc/cinder/:/etc/cinder/:ro
113                   - /var/log/containers/cinder:/var/log/cinder
114             command:
115               - '/usr/bin/bootstrap_host_exec'
116               - 'cinder_api'
117               - "su cinder -s /bin/bash -c 'cinder-manage db sync'"
118         step_4:
119           cinder_api:
120             image: *cinder_api_image
121             net: host
122             privileged: false
123             restart: always
124             # NOTE(mandre) kolla image changes the user to 'cinder', we need it
125             # to be root to run httpd
126             user: root
127             volumes:
128               list_concat:
129                 - {get_attr: [ContainersCommon, volumes]}
130                 -
131                   - /var/lib/kolla/config_files/cinder_api.json:/var/lib/kolla/config_files/config.json:ro
132                   - /var/lib/config-data/cinder/etc/cinder/:/etc/cinder/:ro
133                   - /var/lib/config-data/cinder/etc/httpd/:/etc/httpd/:ro
134                   - /var/lib/config-data/cinder/var/www/:/var/www/:ro
135                   - /var/log/containers/cinder:/var/log/cinder
136                   -
137                     if:
138                       - internal_tls_enabled
139                       - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
140                       - ''
141                   -
142                     if:
143                       - internal_tls_enabled
144                       - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
145                       - ''
146             environment:
147               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
148       host_prep_tasks:
149         - name: create persistent logs directory
150           file:
151             path: /var/log/containers/cinder
152             state: directory
153       upgrade_tasks:
154         - name: Stop and disable cinder_api service
155           tags: step2
156           service: name=httpd state=stopped enabled=no