From e66e5ab7c462d39e2c3681bf30f442a9c5994fdc Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Thu, 15 Mar 2012 15:38:55 -0700 Subject: [PATCH] Add fedora support This commit is a refactor of work performed by Derek Higgins that adds fedora 16 support to these openstack modules. It contains the following: - creates a params class to store all of the data differences. - installs all packages on all nova nodes - introuces an anchor that is used to specify ordering for things that need to occur before nova is installed. - manages libvirt package and service in the nova::compute::libvirt class --- manifests/api.pp | 10 +++------ manifests/compute.pp | 8 ++----- manifests/compute/libvirt.pp | 22 ++++++++++++++++++- manifests/controller.pp | 5 ++++- manifests/db.pp | 4 ++-- manifests/init.pp | 30 ++++++++++++++++++++------ manifests/network.pp | 8 ++----- manifests/network/bridge.pp | 3 +++ manifests/objectstore.pp | 10 ++++----- manifests/params.pp | 42 ++++++++++++++++++++++++++++++++++++ manifests/rabbitmq.pp | 4 ++-- manifests/scheduler.pp | 10 ++++----- 12 files changed, 112 insertions(+), 44 deletions(-) create mode 100644 manifests/params.pp diff --git a/manifests/api.pp b/manifests/api.pp index 164b0cf44..8bbffb483 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -12,18 +12,14 @@ class nova::api($enabled=false) { exec { "initial-db-sync": command => "/usr/bin/nova-manage db sync", refreshonly => true, - require => [Package["nova-common"], Nova_config['sql_connection']], + require => [Package[$::nova::params::package_names], Nova_config['sql_connection']], } - package { "nova-api": - ensure => present, - require => Package["python-greenlet"], - notify => Exec['initial-db-sync'], - } service { "nova-api": + name => $::nova::params::api_service_name, ensure => $service_ensure, enable => $enabled, - require => Package["nova-api"], + require => Package[$::nova::params::package_names], #subscribe => File["/etc/nova/nova.conf"] } } diff --git a/manifests/compute.pp b/manifests/compute.pp index c3acfef75..3ca5da296 100644 --- a/manifests/compute.pp +++ b/manifests/compute.pp @@ -16,15 +16,11 @@ class nova::compute( $service_ensure = 'stopped' } - package { "nova-compute": - ensure => present, - require => Package['nova-common'], - } - service { "nova-compute": + name => $::nova::params::compute_service_name, ensure => $service_ensure, enable => $enabled, - require => Package["nova-compute"], + require => Package[$::nova::params::package_names], before => Exec['networking-refresh'], } diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index 498bf85b6..0d4864aa5 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -3,9 +3,29 @@ class nova::compute::libvirt ( $flat_network_bridge = 'br100', $flat_network_bridge_ip, $flat_network_bridge_netmask -) { +) inherits nova::compute{ + + include nova::params + + package { 'libvirt': + name => $::nova::params::libvirt_package_name, + ensure => present, + } + + service {"libvirt" : + name => $::nova::params::libvirt_service_name, + ensure => running, + provider => $::nova::params::special_service_provider, + require => Package['libvirt'], + } + + Service['nova-compute'] { + require +> Service['libvirt'], + } + nova_config { 'libvirt_type': value => $libvirt_type } nova_config { 'connection_type': value => 'libvirt' } + nova::network::bridge { $flat_network_bridge: ip => $flat_network_bridge_ip, netmask => $flat_network_bridge_netmask, diff --git a/manifests/controller.pp b/manifests/controller.pp index dec89d857..c04015c1a 100644 --- a/manifests/controller.pp +++ b/manifests/controller.pp @@ -56,7 +56,10 @@ class nova::controller( flat_network_bridge_netmask => $flat_network_bridge_netmask, } - class { "nova::objectstore": enabled => true } + class { "nova::objectstore": + enabled => true, + } + class { "nova::scheduler": enabled => true } nova::manage::admin { $admin_user: } diff --git a/manifests/db.pp b/manifests/db.pp index c5393afa9..fc99b476c 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -7,8 +7,8 @@ class nova::db( $cluster_id = 'localzone' ) { - # Create the db instance before nova-common if its installed - Mysql::Db[$dbname] -> Package<| title == "nova-common" |> + # Create the db instance before openstack-nova if its installed + Mysql::Db[$dbname] -> Anchor<| title == "nova-start" |> Mysql::Db[$dbname] ~> Exec<| title == 'initial-db-sync' |> # now this requires storedconfigs diff --git a/manifests/init.pp b/manifests/init.pp index c428e0ed1..6af627d74 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,13 +24,23 @@ class nova( $nodaemon = false, $periodic_interval = '60', $report_interval = '10' + ) { + include nova::params + Nova_config<| |> { - require +> Package["nova-common"], + require +> Package[$::nova::params::package_names], before +> File['/etc/nova/nova.conf'], notify +> Exec['post-nova_config'] } + + File { + require => Package[$::nova::params::package_names], + owner => 'nova', + group => 'nova', + } + # TODO - why is this required? package { 'python': ensure => present, @@ -41,10 +51,21 @@ class nova( } class { 'nova::utilities': } - package { ["python-nova", "nova-common", "nova-doc"]: + + # this anchor is used to simplify the graph between nova components by + # allowing a resource to serve as a point where the configuration of nova begins + anchor { 'nova-start': } + + package { ["python-nova", $::nova::params::doc_package_name]: ensure => present, require => Package["python-greenlet"] } + + package { $::nova::params::package_names: + ensure => present, + require => [Package["python-greenlet"], Anchor['nova-start']] + } + group { 'nova': ensure => present } @@ -55,13 +76,8 @@ class nova( file { $logdir: ensure => directory, mode => '751', - owner => 'nova', - group => 'nova', - require => Package['nova-common'], } file { '/etc/nova/nova.conf': - owner => 'nova', - group => 'nova', mode => '0640', } exec { "nova-db-sync": diff --git a/manifests/network.pp b/manifests/network.pp index db3bc8848..d27d13402 100644 --- a/manifests/network.pp +++ b/manifests/network.pp @@ -9,15 +9,11 @@ class nova::network( $enabled=false ) { $service_ensure = 'stopped' } - package { "nova-network": - ensure => present, - require => Package["python-greenlet"] - } - service { "nova-network": + name => $::nova::params::network_service_name, ensure => $service_ensure, enable => $enabled, - require => Package["nova-network"], + require => Package[$::nova::params::package_names], before => Exec['networking-refresh'], #subscribe => File["/etc/nova/nova.conf"] } diff --git a/manifests/network/bridge.pp b/manifests/network/bridge.pp index c8f48fb68..6f3b3be8a 100644 --- a/manifests/network/bridge.pp +++ b/manifests/network/bridge.pp @@ -20,6 +20,9 @@ define nova::network::bridge ( $ip, $netmask = "255.255.255.0" ) } } + 'fedora' : { + } + default: { fail('nova::network_bridge currently only supports Debian and Ubuntu') } } diff --git a/manifests/objectstore.pp b/manifests/objectstore.pp index fc580abfb..90980d408 100644 --- a/manifests/objectstore.pp +++ b/manifests/objectstore.pp @@ -1,5 +1,7 @@ class nova::objectstore( $enabled=false ) { + include nova::params + Exec['post-nova_config'] ~> Service['nova-objectstore'] Exec['nova-db-sync'] ~> Service['nova-objectstore'] @@ -9,15 +11,11 @@ class nova::objectstore( $enabled=false ) { $service_ensure = 'stopped' } - package { "nova-objectstore": - ensure => present, - require => Package["python-greenlet"] - } - service { "nova-objectstore": + name => $::nova::params::objectstore_service_name, ensure => $service_ensure, enable => $enabled, - require => Package["nova-objectstore"], + require => Package[$::nova::params::package_names], #subscribe => File["/etc/nova/nova.conf"] } } diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 000000000..21549b2af --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,42 @@ +# these parameters need to be accessed from several locations and +# should be considered to be constant +class nova::params { + + case $::osfamily { + 'RedHat': { + $package_names = 'openstack-nova' + $doc_package_name = 'openstack-nova-doc' + $api_service_name = 'openstack-nova-api' + $compute_service_name = 'openstack-nova-compute' + $network_service_name = 'openstack-nova-network' + $objectstore_service_name = 'openstack-nova-objectstore' + $scheduler_service_name = 'openstack-nova-scheduler' + $libvirt_package_name = 'libvirt' + $libvirt_service_name = 'libvirtd' + $special_service_provider = 'init' + } + 'Debian': { + $package_names = ['nova-common', + 'nova-api', + 'nova-compute', + 'nova-network', + 'nova-objectstore', + 'nova-scheduler' + ] + $doc_package_name = 'nova-doc' + $api_service_name = 'nova-api' + $compute_service_name = 'nova-compute' + $network_service_name = 'nova-network' + $objectstore_service_name = 'nova-objectstore' + $scheduler_service_name = 'nova-scheduler' + $libvirt_package_name = 'libvirt-bin' + $libvirt_service_name = 'libvirt-bin' + # some of the services need to be started form the special upstart provider + $special_service_provider = 'upstart' + } + default: { + fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian") + } + } + +} diff --git a/manifests/rabbitmq.pp b/manifests/rabbitmq.pp index b74f5dc94..21404f384 100644 --- a/manifests/rabbitmq.pp +++ b/manifests/rabbitmq.pp @@ -11,7 +11,7 @@ class nova::rabbitmq( ) { # only configure nova after the queue is up - Class['rabbitmq::service'] -> Package<| title == 'nova-common' |> + Class['rabbitmq::service'] -> Anchor<| title == 'nova-start' |> # work around hostname bug, LP #653405 host { $hostname: @@ -42,7 +42,7 @@ class nova::rabbitmq( write_permission => '.*', read_permission => '.*', provider => 'rabbitmqctl', - }->Package<| title == 'nova-common' |> + }->Anchor<| title == 'nova-start' |> } class { 'rabbitmq::server': port => $port, diff --git a/manifests/scheduler.pp b/manifests/scheduler.pp index db288db40..2ef1daff0 100644 --- a/manifests/scheduler.pp +++ b/manifests/scheduler.pp @@ -1,5 +1,7 @@ class nova::scheduler( $enabled ) { + include nova::params + Exec['post-nova_config'] ~> Service['nova-scheduler'] Exec['nova-db-sync'] -> Service['nova-scheduler'] @@ -9,15 +11,11 @@ class nova::scheduler( $enabled ) { $service_ensure = 'stopped' } - package { "nova-scheduler": - ensure => present, - require => Package["python-greenlet"] - } - service { "nova-scheduler": + name => $::nova::params::scheduler_service_name, ensure => $service_ensure, enable => $enabled, - require => Package["nova-scheduler"], + require => Package[$::nova::params::package_names], #subscribe => File["/etc/nova/nova.conf"] } }