1 heat_template_version: pike
4 OpenStack containerized Nova API service
10 DockerNovaConfigImage:
11 description: The container image to use for the nova config_volume
15 description: Mapping of service endpoint -> protocol. Typically set
16 via parameter_defaults in the resource registry.
20 description: Dictionary packing service data
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.
33 description: Role name on which the service is applied
37 description: Parameters specific to the role
42 UpgradeRemoveUnusedPackages:
44 description: Remove package if the service is being disabled during upgrade
49 internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
54 type: ./containers-common.yaml
57 type: ../../puppet/services/database/mysql-client.yaml
60 type: ../../puppet/services/nova-api.yaml
62 EndpointMap: {get_param: EndpointMap}
63 ServiceData: {get_param: ServiceData}
64 ServiceNetMap: {get_param: ServiceNetMap}
65 DefaultPasswords: {get_param: DefaultPasswords}
66 RoleName: {get_param: RoleName}
67 RoleParameters: {get_param: RoleParameters}
71 description: Role data for the Nova API role.
73 service_name: {get_attr: [NovaApiBase, role_data, service_name]}
76 - get_attr: [NovaApiBase, role_data, config_settings]
77 - apache::default_vhost: false
78 logging_source: {get_attr: [NovaApiBase, role_data, logging_source]}
79 logging_groups: {get_attr: [NovaApiBase, role_data, logging_groups]}
80 step_config: &step_config
83 - - "['Nova_cell_v2'].each |String $val| { noop_resource($val) }"
84 - {get_attr: [NovaApiBase, role_data, step_config]}
85 - {get_attr: [MySQLClient, role_data, step_config]}
86 service_config_settings: {get_attr: [NovaApiBase, role_data, service_config_settings]}
87 # BEGIN DOCKER SETTINGS
90 puppet_tags: nova_config
91 step_config: *step_config
92 config_image: {get_param: DockerNovaConfigImage}
94 /var/lib/kolla/config_files/nova_api.json:
95 command: /usr/sbin/httpd -DFOREGROUND
97 - source: "/var/lib/kolla/config_files/src/*"
100 preserve_properties: true
102 - path: /var/log/nova
105 /var/lib/kolla/config_files/nova_api_cron.json:
106 command: /usr/sbin/crond -n
108 - source: "/var/lib/kolla/config_files/src/*"
111 preserve_properties: true
113 - path: /var/log/nova
116 docker_config_scripts:
117 nova_api_discover_hosts.sh:
121 export OS_PROJECT_DOMAIN_NAME=$(crudini --get /etc/nova/nova.conf keystone_authtoken project_domain_name)
122 export OS_USER_DOMAIN_NAME=$(crudini --get /etc/nova/nova.conf keystone_authtoken user_domain_name)
123 export OS_PROJECT_NAME=$(crudini --get /etc/nova/nova.conf keystone_authtoken project_name)
124 export OS_USERNAME=$(crudini --get /etc/nova/nova.conf keystone_authtoken username)
125 export OS_PASSWORD=$(crudini --get /etc/nova/nova.conf keystone_authtoken password)
126 export OS_AUTH_URL=$(crudini --get /etc/nova/nova.conf keystone_authtoken auth_url)
127 export OS_AUTH_TYPE=password
128 export OS_IDENTITY_API_VERSION=3
130 echo "(cellv2) Running cell_v2 host discovery"
133 declare -A discoverable_hosts
134 for host in $(hiera -c /etc/puppet/hiera.yaml cellv2_discovery_hosts | sed -e '/^nil$/d' | tr "," " "); do discoverable_hosts[$host]=1; done
135 timeout_at=$(( $(date +"%s") + ${timeout} ))
136 echo "(cellv2) Waiting ${timeout} seconds for hosts to register"
139 for host in $(openstack -q compute service list -c 'Host' -c 'Zone' -f value | awk '$2 != "internal" { print $1 }'); do
140 if (( discoverable_hosts[$host] == 1 )); then
141 echo "(cellv2) compute node $host has registered"
142 unset discoverable_hosts[$host]
146 for host in "${!discoverable_hosts[@]}"; do
147 if (( ${discoverable_hosts[$host]} == 1 )); then
148 echo "(cellv2) compute node $host has not registered"
152 remaining=$(( $timeout_at - $(date +"%s") ))
153 if (( $finished == 1 )); then
154 echo "(cellv2) All nodes registered"
156 elif (( $remaining <= 0 )); then
157 echo "(cellv2) WARNING: timeout waiting for nodes to register, running host discovery regardless"
158 echo "(cellv2) Expected host list:" $(hiera -c /etc/puppet/hiera.yaml cellv2_discovery_hosts | sed -e '/^nil$/d' | sort -u | tr ',' ' ')
159 echo "(cellv2) Detected host list:" $(openstack -q compute service list -c 'Host' -c 'Zone' -f value | awk '$2 != "internal" { print $1 }' | sort -u | tr '\n', ' ')
162 echo "(cellv2) Waiting ${remaining} seconds for hosts to register"
166 echo "(cellv2) Running host discovery..."
167 su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 discover_hosts --verbose"
168 nova_api_ensure_default_cell.sh:
172 DEFID=$(nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}')
173 if [ "$DEFID" ]; then
174 echo "(cellv2) Updating default cell_v2 cell $DEFID"
175 su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 update_cell --cell_uuid $DEFID --name=default"
177 echo "(cellv2) Creating default cell_v2 cell"
178 su nova -s /bin/bash -c "/usr/bin/nova-manage cell_v2 create_cell --name=default"
181 # db sync runs before permissions set by kolla_config
184 image: &nova_api_image {get_param: DockerNovaApiImage}
188 - /var/log/containers/nova:/var/log/nova
189 - /var/log/containers/httpd/nova-api:/var/log/httpd
190 command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
194 image: *nova_api_image
198 volumes: &nova_api_bootstrap_volumes
200 - {get_attr: [ContainersCommon, volumes]}
202 - /var/lib/config-data/nova/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
203 - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
204 - /var/log/containers/nova:/var/log/nova
205 - /var/log/containers/httpd/nova-api:/var/log/httpd
206 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage api_db sync'"
209 image: *nova_api_image
213 volumes: *nova_api_bootstrap_volumes
214 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'"
215 nova_api_ensure_default_cell:
217 image: *nova_api_image
222 - *nova_api_bootstrap_volumes
224 - /var/lib/config-data/nova/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
225 - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
226 - /var/log/containers/nova:/var/log/nova
227 - /var/lib/docker-config-scripts/nova_api_ensure_default_cell.sh:/nova_api_ensure_default_cell.sh:ro
229 command: "/usr/bin/bootstrap_host_exec nova_api /nova_api_ensure_default_cell.sh"
232 image: *nova_api_image
235 volumes: *nova_api_bootstrap_volumes
237 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db sync'"
241 image: *nova_api_image
248 - {get_attr: [ContainersCommon, volumes]}
250 - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
251 - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
252 - /var/log/containers/nova:/var/log/nova
253 - /var/log/containers/httpd/nova-api:/var/log/httpd
256 - internal_tls_enabled
257 - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
261 - internal_tls_enabled
262 - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
265 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
267 image: *nova_api_image
276 - {get_attr: [ContainersCommon, volumes]}
278 - /var/lib/kolla/config_files/nova_api_cron.json:/var/lib/kolla/config_files/config.json:ro
279 - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
280 - /var/log/containers/nova:/var/log/nova
281 - /var/log/containers/httpd/nova-api:/var/log/httpd
283 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
285 nova_api_discover_hosts:
287 image: *nova_api_image
292 - *nova_api_bootstrap_volumes
294 - /var/lib/config-data/nova/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
295 - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
296 - /var/log/containers/nova:/var/log/nova
297 - /var/lib/docker-config-scripts/nova_api_discover_hosts.sh:/nova_api_discover_hosts.sh:ro
299 command: "/usr/bin/bootstrap_host_exec nova_api /nova_api_discover_hosts.sh"
301 get_attr: [NovaApiBase, role_data, metadata_settings]
303 - name: create persistent logs directory
308 - /var/log/containers/nova
309 - /var/log/containers/httpd/nova-api
311 - name: Stop and disable nova_api service
313 service: name=openstack-nova-api state=stopped enabled=no
314 - name: Remove openstack-nova-api package if operator requests it
315 yum: name=openstack-nova-api state=removed
318 when: {get_param: UpgradeRemoveUnusedPackages}
319 - name: remove old nova cron jobs
322 path: /var/spool/cron/nova