9282c934534c35d9e716df19ea48087f62382543
[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           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       docker_config:
96         # db sync runs before permissions set by kolla_config
97         step_2:
98           nova_init_logs:
99             image: &nova_api_image
100               list_join:
101                 - '/'
102                 - [ {get_param: DockerNamespace}, {get_param: DockerNovaApiImage} ]
103             privileged: false
104             user: root
105             volumes:
106               - /var/log/containers/nova:/var/log/nova
107             command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
108         step_3:
109           nova_api_db_sync:
110             start_order: 0
111             image: *nova_api_image
112             net: host
113             detach: false
114             user: root
115             volumes: &nova_api_bootstrap_volumes
116               list_concat:
117                 - {get_attr: [ContainersCommon, volumes]}
118                 -
119                   - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
120                   - /var/log/containers/nova:/var/log/nova
121             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage api_db sync'"
122           # FIXME: we probably want to wait on the 'cell_v2 update' in order for this
123           # to be capable of upgrading a baremetal setup. This is to ensure the name
124           # of the cell is 'default'
125           nova_api_map_cell0:
126             start_order: 1
127             image: *nova_api_image
128             net: host
129             detach: false
130             user: root
131             volumes: *nova_api_bootstrap_volumes
132             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'"
133           nova_api_create_default_cell:
134             start_order: 2
135             image: *nova_api_image
136             net: host
137             detach: false
138             volumes: *nova_api_bootstrap_volumes
139             # NOTE: allowing the exit code 2 is a dirty way of making
140             # this idempotent (if the resource already exists a conflict
141             # is raised)
142             exit_codes: [0,2]
143             user: root
144             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 create_cell --name=default'"
145           nova_db_sync:
146             start_order: 3
147             image: *nova_api_image
148             net: host
149             detach: false
150             volumes: *nova_api_bootstrap_volumes
151             user: root
152             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db sync'"
153         step_4:
154           nova_api:
155             start_order: 2
156             image: *nova_api_image
157             net: host
158             user: nova
159             privileged: true
160             restart: always
161             volumes: &nova_api_volumes
162               list_concat:
163                 - {get_attr: [ContainersCommon, volumes]}
164                 -
165                   - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
166                   - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
167                   - /var/log/containers/nova:/var/log/nova
168             environment:
169               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
170           nova_api_cron:
171             image: *nova_api_image
172             net: host
173             user: root
174             privileged: true
175             restart: always
176             volumes: *nova_api_volumes
177             environment:
178               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
179             command: "/usr/sbin/crond -n"
180         step_5:
181           nova_api_discover_hosts:
182             start_order: 1
183             image: *nova_api_image
184             net: host
185             detach: false
186             volumes: *nova_api_bootstrap_volumes
187             user: root
188             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 discover_hosts'"
189       host_prep_tasks:
190         - name: create persistent logs directory
191           file:
192             path: /var/log/containers/nova
193             state: directory
194       upgrade_tasks:
195         - name: Stop and disable nova_api service
196           tags: step2
197           service: name=openstack-nova-api state=stopped enabled=no