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