diff --git a/attributes/default.rb b/attributes/default.rb index d1fc7247..d95885d2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -298,8 +298,8 @@ default['openstack']['network']['dhcp']['enable_metadata_network'] = 'False' # the version of dnsmasq for centos 6.5 is two revs behind where the dhcp-agent needs # to run properly. This is a version that allows and starts the dhcp-agent correctly. -default['openstack']['network']['dhcp']['dnsmasq_rpm_source'] = "http://pkgs.repoforge.org/dnsmasq/dnsmasq-#{node['openstack']['network']['dhcp']['dnsmasq_rpm_version']}.rpm" default['openstack']['network']['dhcp']['dnsmasq_rpm_version'] = '2.65-1.el6.rfx.x86_64' +default['openstack']['network']['dhcp']['dnsmasq_rpm_source'] = "http://pkgs.repoforge.org/dnsmasq/dnsmasq-#{node['openstack']['network']['dhcp']['dnsmasq_rpm_version']}.rpm" # The package architecture that will be built which should match the # archecture of the server this cookbook will run on which will be diff --git a/recipes/dhcp_agent.rb b/recipes/dhcp_agent.rb index 14ee826f..09498678 100644 --- a/recipes/dhcp_agent.rb +++ b/recipes/dhcp_agent.rb @@ -74,13 +74,14 @@ when 'centos' remote_file dnsmasq_file do source node['openstack']['network']['dhcp']['dnsmasq_rpm_source'] - not_if { ::File.exists?(dnsmasq_file) } + not_if { ::File.exists?(dnsmasq_file) || node['openstack']['network']['dhcp']['dnsmasq_rpm_version'].to_s.empty? } end rpm_package 'dnsmasq' do source dnsmasq_file action :install notifies :restart, 'service[neutron-dhcp-agent]', :immediately + not_if { node['openstack']['network']['dhcp']['dnsmasq_rpm_version'].to_s.empty? } end end end diff --git a/spec/dhcp_agent-centos_spec.rb b/spec/dhcp_agent-centos_spec.rb index d2d3f249..8474d9d9 100644 --- a/spec/dhcp_agent-centos_spec.rb +++ b/spec/dhcp_agent-centos_spec.rb @@ -8,7 +8,6 @@ describe 'openstack-network::dhcp_agent' do let(:node) { runner.node } let(:chef_run) do node.set['openstack']['compute']['network']['service_type'] = 'neutron' - node.set['openstack']['compute']['network']['dhcp']['dnsmasq_rpm_source'] = 'http://pkgs.repoforge.org/dnsmasq/dnsmasq-2.65-1.el6.rfx.x86_64.rpm' runner.converge(described_recipe) end @@ -36,7 +35,7 @@ describe 'openstack-network::dhcp_agent' do end it 'should have the correct dnsmasq remote file' do - expect(chef_run).to create_remote_file("#{Chef::Config[:file_cache_path]}/2.65-1.el6.rfx.x86_64").with(source: 'http://pkgs.repoforge.org/dnsmasq/dnsmasq-.rpm') + expect(chef_run).to create_remote_file("#{Chef::Config[:file_cache_path]}/2.65-1.el6.rfx.x86_64").with(source: 'http://pkgs.repoforge.org/dnsmasq/dnsmasq-2.65-1.el6.rfx.x86_64.rpm') end it 'should install the corrcet dnsmasq rpm' do @@ -47,6 +46,11 @@ describe 'openstack-network::dhcp_agent' do expect(chef_run.rpm_package('dnsmasq')).to notify('service[neutron-dhcp-agent]').to(:restart).immediately end + it 'should not have the correct dnsmasq remote file when no version' do + node.set['openstack']['network']['dhcp']['dnsmasq_rpm_version'] = '' + expect(chef_run).not_to create_remote_file("#{Chef::Config[:file_cache_path]}/2.65-1.el6.rfx.x86_64") + end + describe '/etc/neutron/dhcp_agent.ini' do let(:file) { chef_run.template('/etc/neutron/dhcp_agent.ini') }