Merge "List all unhealthy containers" into stable/pike
[apex-tripleo-heat-templates.git] / docker / services / nova-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Nova API service
5
6 parameters:
7   DockerNovaApiImage:
8     description: image
9     type: string
10   DockerNovaConfigImage:
11     description: The container image to use for the nova 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
43 conditions:
44
45   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
46
47 resources:
48
49   ContainersCommon:
50     type: ./containers-common.yaml
51
52   MySQLClient:
53     type: ../../puppet/services/database/mysql-client.yaml
54
55   NovaApiBase:
56     type: ../../puppet/services/nova-api.yaml
57     properties:
58       EndpointMap: {get_param: EndpointMap}
59       ServiceData: {get_param: ServiceData}
60       ServiceNetMap: {get_param: ServiceNetMap}
61       DefaultPasswords: {get_param: DefaultPasswords}
62       RoleName: {get_param: RoleName}
63       RoleParameters: {get_param: RoleParameters}
64
65 outputs:
66   role_data:
67     description: Role data for the Nova API role.
68     value:
69       service_name: {get_attr: [NovaApiBase, role_data, service_name]}
70       config_settings:
71         map_merge:
72           - get_attr: [NovaApiBase, role_data, config_settings]
73           - apache::default_vhost: false
74       logging_source: {get_attr: [NovaApiBase, role_data, logging_source]}
75       logging_groups: {get_attr: [NovaApiBase, role_data, logging_groups]}
76       step_config: &step_config
77         list_join:
78           - "\n"
79           - - "['Nova_cell_v2'].each |String $val| { noop_resource($val) }"
80             - {get_attr: [NovaApiBase, role_data, step_config]}
81             - {get_attr: [MySQLClient, role_data, step_config]}
82       service_config_settings: {get_attr: [NovaApiBase, role_data, service_config_settings]}
83       # BEGIN DOCKER SETTINGS
84       puppet_config:
85         config_volume: nova
86         puppet_tags: nova_config
87         step_config: *step_config
88         config_image: {get_param: DockerNovaConfigImage}
89       kolla_config:
90         /var/lib/kolla/config_files/nova_api.json:
91           command: /usr/sbin/httpd -DFOREGROUND
92           config_files:
93             - source: "/var/lib/kolla/config_files/src/*"
94               dest: "/"
95               merge: true
96               preserve_properties: true
97           permissions:
98             - path: /var/log/nova
99               owner: nova:nova
100               recurse: true
101         /var/lib/kolla/config_files/nova_api_cron.json:
102           command: /usr/sbin/crond -n
103           config_files:
104             - source: "/var/lib/kolla/config_files/src/*"
105               dest: "/"
106               merge: true
107               preserve_properties: true
108           permissions:
109             - path: /var/log/nova
110               owner: nova:nova
111               recurse: true
112       docker_config:
113         # db sync runs before permissions set by kolla_config
114         step_2:
115           nova_init_logs:
116             image: &nova_api_image {get_param: DockerNovaApiImage}
117             privileged: false
118             user: root
119             volumes:
120               - /var/log/containers/nova:/var/log/nova
121               - /var/log/containers/httpd/nova-api:/var/log/httpd
122             command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
123         step_3:
124           nova_api_db_sync:
125             start_order: 0
126             image: *nova_api_image
127             net: host
128             detach: false
129             user: root
130             volumes: &nova_api_bootstrap_volumes
131               list_concat:
132                 - {get_attr: [ContainersCommon, volumes]}
133                 -
134                   - /var/lib/config-data/nova/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
135                   - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
136                   - /var/log/containers/nova:/var/log/nova
137                   - /var/log/containers/httpd/nova-api:/var/log/httpd
138             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage api_db sync'"
139           # FIXME: we probably want to wait on the 'cell_v2 update' in order for this
140           # to be capable of upgrading a baremetal setup. This is to ensure the name
141           # of the cell is 'default'
142           nova_api_map_cell0:
143             start_order: 1
144             image: *nova_api_image
145             net: host
146             detach: false
147             user: root
148             volumes: *nova_api_bootstrap_volumes
149             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'"
150           nova_api_create_default_cell:
151             start_order: 2
152             image: *nova_api_image
153             net: host
154             detach: false
155             volumes: *nova_api_bootstrap_volumes
156             # NOTE: allowing the exit code 2 is a dirty way of making
157             # this idempotent (if the resource already exists a conflict
158             # is raised)
159             exit_codes: [0,2]
160             user: root
161             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 create_cell --name=default'"
162           nova_db_sync:
163             start_order: 3
164             image: *nova_api_image
165             net: host
166             detach: false
167             volumes: *nova_api_bootstrap_volumes
168             user: root
169             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db sync'"
170         step_4:
171           nova_api:
172             start_order: 2
173             image: *nova_api_image
174             net: host
175             user: root
176             privileged: true
177             restart: always
178             volumes:
179               list_concat:
180                 - {get_attr: [ContainersCommon, volumes]}
181                 -
182                   - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
183                   - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
184                   - /var/log/containers/nova:/var/log/nova
185                   - /var/log/containers/httpd/nova-api:/var/log/httpd
186                   -
187                     if:
188                       - internal_tls_enabled
189                       - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
190                       - ''
191                   -
192                     if:
193                       - internal_tls_enabled
194                       - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
195                       - ''
196             environment:
197               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
198           nova_api_cron:
199             image: *nova_api_image
200             net: host
201             user: root
202             privileged: false
203             restart: always
204             healthcheck:
205               test: /bin/true
206             volumes:
207               list_concat:
208                 - {get_attr: [ContainersCommon, volumes]}
209                 -
210                   - /var/lib/kolla/config_files/nova_api_cron.json:/var/lib/kolla/config_files/config.json:ro
211                   - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
212                   - /var/log/containers/nova:/var/log/nova
213                   - /var/log/containers/httpd/nova-api:/var/log/httpd
214             environment:
215               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
216         step_5:
217           nova_api_discover_hosts:
218             start_order: 1
219             image: *nova_api_image
220             net: host
221             detach: false
222             volumes: *nova_api_bootstrap_volumes
223             user: root
224             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 discover_hosts --verbose'"
225       metadata_settings:
226         get_attr: [NovaApiBase, role_data, metadata_settings]
227       host_prep_tasks:
228         - name: create persistent logs directory
229           file:
230             path: "{{ item }}"
231             state: directory
232           with_items:
233             - /var/log/containers/nova
234             - /var/log/containers/httpd/nova-api
235       upgrade_tasks:
236         - name: Stop and disable nova_api service
237           tags: step2
238           service: name=openstack-nova-api state=stopped enabled=no
239         - name: remove old nova cron jobs
240           file:
241             path: /var/spool/cron/nova
242             state: absent