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