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   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerNovaApiImage:
12     description: image
13     default: 'centos-binary-nova-api:latest'
14     type: string
15   DockerNovaConfigImage:
16     description: The container image to use for the nova config_volume
17     default: 'centos-binary-nova-base:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceNetMap:
25     default: {}
26     description: Mapping of service_name -> network name. Typically set
27                  via parameter_defaults in the resource registry.  This
28                  mapping overrides those in ServiceNetMapDefaults.
29     type: json
30   DefaultPasswords:
31     default: {}
32     type: json
33   RoleName:
34     default: ''
35     description: Role name on which the service is applied
36     type: string
37   RoleParameters:
38     default: {}
39     description: Parameters specific to the role
40     type: json
41
42 resources:
43
44   ContainersCommon:
45     type: ./containers-common.yaml
46
47   NovaApiBase:
48     type: ../../puppet/services/nova-api.yaml
49     properties:
50       EndpointMap: {get_param: EndpointMap}
51       ServiceNetMap: {get_param: ServiceNetMap}
52       DefaultPasswords: {get_param: DefaultPasswords}
53       RoleName: {get_param: RoleName}
54       RoleParameters: {get_param: RoleParameters}
55
56 outputs:
57   role_data:
58     description: Role data for the Nova API role.
59     value:
60       service_name: {get_attr: [NovaApiBase, role_data, service_name]}
61       config_settings:
62         map_merge:
63           - get_attr: [NovaApiBase, role_data, config_settings]
64           - apache::default_vhost: false
65             nova_wsgi_enabled: false
66             nova::api::service_name: '%{::nova::params::api_service_name}'
67             nova::wsgi::apache_api::ssl: false
68       step_config: &step_config
69         list_join:
70           - "\n"
71           - - "['Nova_cell_v2'].each |String $val| { noop_resource($val) }"
72             - {get_attr: [NovaApiBase, 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:
80           list_join:
81           - '/'
82           - [ {get_param: DockerNamespace}, {get_param: DockerNovaConfigImage} ]
83       kolla_config:
84         /var/lib/kolla/config_files/nova_api.json:
85           command: /usr/bin/nova-api
86           permissions:
87             - path: /var/log/nova
88               owner: nova:nova
89               recurse: true
90       docker_config:
91         # db sync runs before permissions set by kolla_config
92         step_2:
93           nova_init_logs:
94             image: &nova_api_image
95               list_join:
96                 - '/'
97                 - [ {get_param: DockerNamespace}, {get_param: DockerNovaApiImage} ]
98             privileged: false
99             user: root
100             volumes:
101               - /var/log/containers/nova:/var/log/nova
102             command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
103         step_3:
104           nova_api_db_sync:
105             start_order: 0
106             image: *nova_api_image
107             net: host
108             detach: false
109             user: root
110             volumes: &nova_api_volumes
111               list_concat:
112                 - {get_attr: [ContainersCommon, volumes]}
113                 -
114                   - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
115                   - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
116                   - /var/log/containers/nova:/var/log/nova
117             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage api_db sync'"
118           # FIXME: we probably want to wait on the 'cell_v2 update' in order for this
119           # to be capable of upgrading a baremetal setup. This is to ensure the name
120           # of the cell is 'default'
121           nova_api_map_cell0:
122             start_order: 1
123             image: *nova_api_image
124             net: host
125             detach: false
126             user: root
127             volumes: *nova_api_volumes
128             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'"
129           nova_api_create_default_cell:
130             start_order: 2
131             image: *nova_api_image
132             net: host
133             detach: false
134             volumes: *nova_api_volumes
135             # NOTE: allowing the exit code 2 is a dirty way of making
136             # this idempotent (if the resource already exists a conflict
137             # is raised)
138             exit_codes: [0,2]
139             user: root
140             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 create_cell --name=default'"
141           nova_db_sync:
142             start_order: 3
143             image: *nova_api_image
144             net: host
145             detach: false
146             volumes: *nova_api_volumes
147             user: root
148             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db sync'"
149         step_4:
150           nova_api:
151             start_order: 2
152             image: *nova_api_image
153             net: host
154             user: nova
155             privileged: true
156             restart: always
157             volumes: *nova_api_volumes
158             environment:
159               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
160         step_5:
161           nova_api_discover_hosts:
162             start_order: 1
163             image: *nova_api_image
164             net: host
165             detach: false
166             volumes: *nova_api_volumes
167             user: root
168             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 discover_hosts'"
169       host_prep_tasks:
170         - name: create persistent logs directory
171           file:
172             path: /var/log/containers/nova
173             state: directory
174       upgrade_tasks:
175         - name: Stop and disable nova_api service
176           tags: step2
177           service: name=openstack-nova-api state=stopped enabled=no