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"
169 # db sync runs before permissions set by kolla_config
172 image: &nova_api_image {get_param: DockerNovaApiImage}
176 - /var/log/containers/nova:/var/log/nova
177 - /var/log/containers/httpd/nova-api:/var/log/httpd
178 command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
182 image: *nova_api_image
186 volumes: &nova_api_bootstrap_volumes
188 - {get_attr: [ContainersCommon, volumes]}
190 - /var/lib/config-data/nova/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
191 - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
192 - /var/log/containers/nova:/var/log/nova
193 - /var/log/containers/httpd/nova-api:/var/log/httpd
194 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage api_db sync'"
195 # FIXME: we probably want to wait on the 'cell_v2 update' in order for this
196 # to be capable of upgrading a baremetal setup. This is to ensure the name
197 # of the cell is 'default'
200 image: *nova_api_image
204 volumes: *nova_api_bootstrap_volumes
205 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'"
206 nova_api_create_default_cell:
208 image: *nova_api_image
211 volumes: *nova_api_bootstrap_volumes
212 # NOTE: allowing the exit code 2 is a dirty way of making
213 # this idempotent (if the resource already exists a conflict
217 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 create_cell --name=default'"
220 image: *nova_api_image
223 volumes: *nova_api_bootstrap_volumes
225 command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db sync'"
229 image: *nova_api_image
236 - {get_attr: [ContainersCommon, volumes]}
238 - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
239 - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
240 - /var/log/containers/nova:/var/log/nova
241 - /var/log/containers/httpd/nova-api:/var/log/httpd
244 - internal_tls_enabled
245 - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
249 - internal_tls_enabled
250 - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
253 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
255 image: *nova_api_image
264 - {get_attr: [ContainersCommon, volumes]}
266 - /var/lib/kolla/config_files/nova_api_cron.json:/var/lib/kolla/config_files/config.json:ro
267 - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
268 - /var/log/containers/nova:/var/log/nova
269 - /var/log/containers/httpd/nova-api:/var/log/httpd
271 - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
273 nova_api_discover_hosts:
275 image: *nova_api_image
280 - *nova_api_bootstrap_volumes
282 - /var/lib/config-data/nova/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
283 - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
284 - /var/log/containers/nova:/var/log/nova
285 - /var/lib/docker-config-scripts/nova_api_discover_hosts.sh:/nova_api_discover_hosts.sh:ro
287 command: "/usr/bin/bootstrap_host_exec nova_api /nova_api_discover_hosts.sh"
289 get_attr: [NovaApiBase, role_data, metadata_settings]
291 - name: create persistent logs directory
296 - /var/log/containers/nova
297 - /var/log/containers/httpd/nova-api
299 - name: Stop and disable nova_api service
301 service: name=openstack-nova-api state=stopped enabled=no
302 - name: Remove openstack-nova-api package if operator requests it
303 yum: name=openstack-nova-api state=removed
306 when: {get_param: UpgradeRemoveUnusedPackages}
307 - name: remove old nova cron jobs
310 path: /var/spool/cron/nova