Install nova packages per service
This commit ensures that the individual Ubuntu nova packages for any given service are only installed when that service is configured. This behavior was broken when RedHat support was added. Since Redhat only has a single package, it was assumed that all packages should always be installed on all nodes. This was causing all services to be in a running state on Ubuntu (b/c the packages were starting the related service)
This commit is contained in:
@@ -12,14 +12,23 @@ class nova::api($enabled=false) {
|
||||
exec { "initial-db-sync":
|
||||
command => "/usr/bin/nova-manage db sync",
|
||||
refreshonly => true,
|
||||
require => [Package[$::nova::params::package_names], Nova_config['sql_connection']],
|
||||
require => [Package[$::nova::params::common_package_name], Nova_config['sql_connection']],
|
||||
}
|
||||
|
||||
if($::nova::params::api_package_name != undef) {
|
||||
package { 'nova-api':
|
||||
name => $::nova::params::api_package_name,
|
||||
ensure => present,
|
||||
notify => Service['nova-api'],
|
||||
before => Exec['initial-db-sync']
|
||||
}
|
||||
}
|
||||
|
||||
service { "nova-api":
|
||||
name => $::nova::params::api_service_name,
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
require => Package[$::nova::params::package_names],
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
#subscribe => File["/etc/nova/nova.conf"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
# this class should probably never be declared except
|
||||
#schedulee this class should probably never be declared except
|
||||
# from the virtualization implementation of the compute node
|
||||
class nova::compute(
|
||||
$api_server,
|
||||
$enabled = false,
|
||||
$api_port = 8773,
|
||||
$aws_address = '169.254.169.254'
|
||||
) {
|
||||
|
||||
Exec['post-nova_config'] ~> Service['nova-compute']
|
||||
@@ -16,18 +13,19 @@ class nova::compute(
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
if($::nova::params::compute_package_name != undef) {
|
||||
package { 'nova-compute':
|
||||
name => $::nova::params::compute_package_name,
|
||||
ensure => present,
|
||||
notify => Service['nova-compute'],
|
||||
}
|
||||
}
|
||||
|
||||
service { "nova-compute":
|
||||
name => $::nova::params::compute_service_name,
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
require => Package[$::nova::params::package_names],
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
before => Exec['networking-refresh'],
|
||||
}
|
||||
|
||||
# forward guest metadata requests to correct API server
|
||||
# exec { "forward_api_requests":
|
||||
# command => "/sbin/iptables -t nat -A PREROUTING -d ${aws_address}/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination ${api_server}:${api_port}",
|
||||
# unless => "/sbin/iptables -L PREROUTING -t nat -n | egrep 'DNAT[ ]+tcp+[ ]+--[ ]+0.0.0.0\\/0+[ ]+${aws_address}+[ ]+tcp+[ ]+dpt:80+[ ]+to:${api_server}:${api_port}'",
|
||||
# logoutput => on_failure
|
||||
# }
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ class nova(
|
||||
) inherits nova::params {
|
||||
|
||||
Nova_config<| |> {
|
||||
require +> Package[$::nova::params::package_names],
|
||||
require +> Package[$::nova::params::common_package_name],
|
||||
before +> File['/etc/nova/nova.conf'],
|
||||
notify +> Exec['post-nova_config']
|
||||
}
|
||||
|
||||
File {
|
||||
require => Package[$::nova::params::package_names],
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
owner => 'nova',
|
||||
group => 'nova',
|
||||
}
|
||||
@@ -59,7 +59,8 @@ class nova(
|
||||
require => Package["python-greenlet"]
|
||||
}
|
||||
|
||||
package { $::nova::params::package_names:
|
||||
package { 'nova-common':
|
||||
name =>$::nova::params::common_package_name,
|
||||
ensure => present,
|
||||
require => [Package["python-greenlet"], Anchor['nova-start']]
|
||||
}
|
||||
|
||||
@@ -9,11 +9,19 @@ class nova::network( $enabled=false ) {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
if($::nova::params::network_package_name != undef) {
|
||||
package { 'nova-network':
|
||||
name => $::nova::params::network_package_name,
|
||||
ensure => present,
|
||||
notify => Service['nova-network'],
|
||||
}
|
||||
}
|
||||
|
||||
service { "nova-network":
|
||||
name => $::nova::params::network_service_name,
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
require => Package[$::nova::params::package_names],
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
before => Exec['networking-refresh'],
|
||||
#subscribe => File["/etc/nova/nova.conf"]
|
||||
}
|
||||
|
||||
@@ -11,11 +11,19 @@ class nova::objectstore( $enabled=false ) {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
if($::nova::params::objectstore_package_name != undef) {
|
||||
package { 'nova-objectstore':
|
||||
name => $::nova::params::objectstore_package_name,
|
||||
ensure => present,
|
||||
notify => Service['nova-objectstore'],
|
||||
}
|
||||
}
|
||||
|
||||
service { "nova-objectstore":
|
||||
name => $::nova::params::objectstore_service_name,
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
require => Package[$::nova::params::package_names],
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
#subscribe => File["/etc/nova/nova.conf"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,12 @@ class nova::params {
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$package_names = 'openstack-nova'
|
||||
$common_package_name = 'openstack-nova'
|
||||
$api_package_name = undef
|
||||
$compute_package_name = undef
|
||||
$network_package_name = undef
|
||||
$objectstore_package_name = undef
|
||||
$scheduler_package_name = undef
|
||||
$doc_package_name = 'openstack-nova-doc'
|
||||
$api_service_name = 'openstack-nova-api'
|
||||
$compute_service_name = 'openstack-nova-compute'
|
||||
@@ -18,13 +23,12 @@ class nova::params {
|
||||
$root_helper = 'sudo nova-rootwrap'
|
||||
}
|
||||
'Debian': {
|
||||
$package_names = ['nova-common',
|
||||
'nova-api',
|
||||
'nova-compute',
|
||||
'nova-network',
|
||||
'nova-objectstore',
|
||||
'nova-scheduler'
|
||||
]
|
||||
$common_package_name = 'nova-common'
|
||||
$api_package_name = 'nova-api'
|
||||
$compute_package_name = 'nova-compute'
|
||||
$network_package_name = 'nova-network'
|
||||
$objectstore_package_name = 'nova-objectstore'
|
||||
$scheduler_package_name = 'nova-scheduler'
|
||||
$doc_package_name = 'nova-doc'
|
||||
$api_service_name = 'nova-api'
|
||||
$compute_service_name = 'nova-compute'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class nova::scheduler( $enabled ) {
|
||||
class nova::scheduler( $enabled = false) {
|
||||
|
||||
include nova::params
|
||||
|
||||
@@ -11,11 +11,19 @@ class nova::scheduler( $enabled ) {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
if($::nova::params::scheduler_package_name != undef) {
|
||||
package { 'nova-scheduler':
|
||||
name => $::nova::params::scheduler_package_name,
|
||||
ensure => present,
|
||||
notify => Service['nova-scheduler'],
|
||||
}
|
||||
}
|
||||
|
||||
service { "nova-scheduler":
|
||||
name => $::nova::params::scheduler_service_name,
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
require => Package[$::nova::params::package_names],
|
||||
require => Package[$::nova::params::common_package_name],
|
||||
#subscribe => File["/etc/nova/nova.conf"]
|
||||
}
|
||||
}
|
||||
|
||||
54
spec/classes/nova_api_spec.rb
Normal file
54
spec/classes/nova_api_spec.rb
Normal file
@@ -0,0 +1,54 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::api' do
|
||||
|
||||
let :pre_condition do
|
||||
'include nova'
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it{ should contain_exec('initial-db-sync').with(
|
||||
'command' => '/usr/bin/nova-manage db sync',
|
||||
'refreshonly' => true
|
||||
)}
|
||||
it { should contain_service('nova-api').with(
|
||||
'name' => 'nova-api',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should contain_package('nova-api').with(
|
||||
'name' => 'nova-api',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-api]',
|
||||
'before' => 'Exec[initial-db-sync]'
|
||||
) }
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{:enabled => true}
|
||||
end
|
||||
it { should contain_service('nova-api').with(
|
||||
'name' => 'nova-api',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'on rhel' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
it{ should contain_exec('initial-db-sync').with(
|
||||
'command' => '/usr/bin/nova-manage db sync',
|
||||
'refreshonly' => true
|
||||
)}
|
||||
it { should contain_service('nova-api').with(
|
||||
'name' => 'openstack-nova-api',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should_not contain_package('nova-api') }
|
||||
end
|
||||
end
|
||||
45
spec/classes/nova_compute_spec.rb
Normal file
45
spec/classes/nova_compute_spec.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::compute' do
|
||||
|
||||
let :pre_condition do
|
||||
'include nova'
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should contain_service('nova-compute').with(
|
||||
'name' => 'nova-compute',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should contain_package('nova-compute').with(
|
||||
'name' => 'nova-compute',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-compute]'
|
||||
) }
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{:enabled => true}
|
||||
end
|
||||
it { should contain_service('nova-compute').with(
|
||||
'name' => 'nova-compute',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'on rhel' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
it { should contain_service('nova-compute').with(
|
||||
'name' => 'openstack-nova-compute',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should_not contain_package('nova-compute') }
|
||||
end
|
||||
end
|
||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
||||
describe 'nova' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
end
|
||||
|
||||
it do
|
||||
should contain_group('nova').with(
|
||||
@@ -21,4 +21,13 @@ describe 'nova' do
|
||||
'require' => 'Package[nova-common]'
|
||||
)
|
||||
end
|
||||
describe "When platform is RedHat" do
|
||||
let :facts do
|
||||
{:osfamily => 'RedHat'}
|
||||
end
|
||||
it { should contain_package('nova-common').with(
|
||||
'name' => 'openstack-nova',
|
||||
'ensure' => 'present'
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
45
spec/classes/nova_network_spec.rb
Normal file
45
spec/classes/nova_network_spec.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::network' do
|
||||
|
||||
let :pre_condition do
|
||||
'include nova'
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should contain_package('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-network]'
|
||||
) }
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{:enabled => true}
|
||||
end
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'nova-network',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'on rhel' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
it { should contain_service('nova-network').with(
|
||||
'name' => 'openstack-nova-network',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should_not contain_package('nova-network') }
|
||||
end
|
||||
end
|
||||
45
spec/classes/nova_objectstore_spec.rb
Normal file
45
spec/classes/nova_objectstore_spec.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::objectstore' do
|
||||
|
||||
let :pre_condition do
|
||||
'include nova'
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should contain_service('nova-objectstore').with(
|
||||
'name' => 'nova-objectstore',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should contain_package('nova-objectstore').with(
|
||||
'name' => 'nova-objectstore',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-objectstore]'
|
||||
) }
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{:enabled => true}
|
||||
end
|
||||
it { should contain_service('nova-objectstore').with(
|
||||
'name' => 'nova-objectstore',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'on rhel' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
it { should contain_service('nova-objectstore').with(
|
||||
'name' => 'openstack-nova-objectstore',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should_not contain_package('nova-objectstore') }
|
||||
end
|
||||
end
|
||||
45
spec/classes/nova_scheduler_spec.rb
Normal file
45
spec/classes/nova_scheduler_spec.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'nova::scheduler' do
|
||||
|
||||
let :pre_condition do
|
||||
'include nova'
|
||||
end
|
||||
|
||||
describe 'on debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
it { should contain_service('nova-scheduler').with(
|
||||
'name' => 'nova-scheduler',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should contain_package('nova-scheduler').with(
|
||||
'name' => 'nova-scheduler',
|
||||
'ensure' => 'present',
|
||||
'notify' => 'Service[nova-scheduler]'
|
||||
) }
|
||||
describe 'with enabled as true' do
|
||||
let :params do
|
||||
{:enabled => true}
|
||||
end
|
||||
it { should contain_service('nova-scheduler').with(
|
||||
'name' => 'nova-scheduler',
|
||||
'ensure' => 'running',
|
||||
'enable' => true
|
||||
)}
|
||||
end
|
||||
end
|
||||
describe 'on rhel' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
it { should contain_service('nova-scheduler').with(
|
||||
'name' => 'openstack-nova-scheduler',
|
||||
'ensure' => 'stopped',
|
||||
'enable' => false
|
||||
)}
|
||||
it { should_not contain_package('nova-scheduler') }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user