placement_api: create valid apache config before installing package

If apache is (re)starting while the chef-client installs the
nova-placement-api package, it may pick up the vanilla apache2 conf file
before chef-client gets around to fixing it which may result in apache2
failing due to a non-working configuration.

This changeset eliminates the race by creating a valid configuration
before installing the software. The solution is based on the assumption
that no reasonably configured package manager will overwrite an
existing, user-created configuration file.

backport: queens

Change-Id: Id9f1d165411fc5b3cc73b29a36840cf4dc63d81b
(cherry picked from commit ff074af903)
This commit is contained in:
Roger Luethi 2019-07-16 15:50:46 +02:00 committed by Jens Harbott (frickler)
parent 421ae68912
commit 33aa18a008
2 changed files with 27 additions and 26 deletions

View File

@ -5,7 +5,7 @@ issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_u
source_url 'https://github.com/openstack/cookbook-openstack-compute' if respond_to?(:source_url)
license 'Apache-2.0'
description 'The OpenStack Compute service Nova.'
version '17.0.1'
version '17.1.0'
chef_version '>= 12.5' if respond_to?(:chef_version)
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))

View File

@ -24,31 +24,7 @@ end
include_recipe 'openstack-compute::nova-common'
platform_options = node['openstack']['compute']['platform']
platform_options['api_placement_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
nova_user = node['openstack']['compute']['user']
nova_group = node['openstack']['compute']['group']
execute 'placement-api: nova-manage api_db sync' do
timeout node['openstack']['compute']['dbsync_timeout']
user nova_user
group nova_group
command 'nova-manage api_db sync'
action :run
end
service 'disable nova-placement-api service' do
service_name platform_options['api_placement_service']
supports status: true, restart: true
action [:disable, :stop]
end
# Create valid apache site configuration file before installing package
bind_service = node['openstack']['bind_service']['all']['placement-api']
web_app 'nova-placement-api' do
@ -70,3 +46,28 @@ web_app 'nova-placement-api' do
protocol node['openstack']['compute']['placement']['ssl']['protocol']
ciphers node['openstack']['compute']['placement']['ssl']['ciphers']
end
platform_options = node['openstack']['compute']['platform']
platform_options['api_placement_packages'].each do |pkg|
package pkg do
options platform_options['package_overrides']
action :upgrade
end
end
service 'disable nova-placement-api service' do
service_name platform_options['api_placement_service']
supports status: true, restart: true
action [:disable, :stop]
end
nova_user = node['openstack']['compute']['user']
nova_group = node['openstack']['compute']['group']
execute 'placement-api: nova-manage api_db sync' do
timeout node['openstack']['compute']['dbsync_timeout']
user nova_user
group nova_group
command 'nova-manage api_db sync'
action :run
end