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