Merge pull request #50 from bodepd/dev

Massive branch
This commit is contained in:
Dan Bode 2012-03-21 15:10:00 -07:00
commit 5e9db74a25
20 changed files with 452 additions and 49 deletions

181
examples/site.pp Normal file
View File

@ -0,0 +1,181 @@
$db_host = 'db'
$db_username = 'nova'
$db_name = 'nova'
$db_password = 'password'
$rabbit_user = 'nova'
$rabbit_password = 'nova'
$rabbit_vhost = '/'
$rabbit_host = 'rabbitmq'
$rabbit_port = '5672'
$glance_api_servers = 'glance:9292'
$glance_host = 'glance'
$glance_port = '9292'
$api_server = 'controller'
resources { 'nova_config':
purge => true,
}
# this is a hack that I have to do b/c openstack nova
# sets up a route to reroute calls to the metadata server
# to its own server which fails
file { '/usr/lib/ruby/1.8/facter/ec2.rb':
ensure => absent,
}
node db {
class { 'mysql::server':
config_hash => {
'bind_address' => '0.0.0.0'
#'root_password' => 'foo',
#'etc_root_password' => true
}
}
class { 'mysql::ruby': }
class { 'nova::db':
password => $db_password,
dbname => $db_name,
user => $db_username,
host => $clientcert,
# does glance need access?
allowed_hosts => ['controller', 'glance', 'compute'],
}
}
node controller {
class { 'nova::controller':
db_password => $db_password,
db_name => $db_name,
db_user => $db_username,
db_host => $db_host,
rabbit_password => $rabbit_password,
rabbit_port => $rabbit_port,
rabbit_userid => $rabbit_user,
rabbit_virtual_host => $rabbit_vhost,
rabbit_host => $rabbit_host,
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => $glance_api_servers,
glance_host => $glance_host,
glance_port => $glance_port,
libvirt_type => 'qemu',
}
}
node compute {
class { 'nova::compute':
api_server => $api_server,
enabled => true,
api_port => 8773,
aws_address => '169.254.169.254',
}
class { 'nova::compute::libvirt':
libvirt_type => 'qemu',
flat_network_bridge => 'br100',
flat_network_bridge_ip => '11.0.0.1',
flat_network_bridge_netmask => '255.255.255.0',
}
class { "nova":
verbose => $verbose,
sql_connection => "mysql://${db_username}:${db_password}@${db_host}/${db_name}",
image_service => 'nova.image.glance.GlanceImageService',
glance_api_servers => $glance_api_servers,
glance_host => $glance_host,
glance_port => $glance_port,
rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port,
rabbit_userid => $rabbit_user,
rabbit_password => $rabbit_password,
rabbit_virtual_host => $rabbit_virtual_host,
}
}
node glance {
# set up glance server
class { 'glance::api':
swift_store_user => 'foo_user',
swift_store_key => 'foo_pass',
}
class { 'glance::registry': }
}
node rabbitmq {
if($::operatingsystem == 'Ubuntu') {
class { 'rabbitmq::repo::apt': }
}
class { 'nova::rabbitmq':
userid => $rabbit_user,
password => $rabbit_password,
port => $rabbit_port,
virtual_host => $rabbit_vhost,
}
}
node puppetmaster {
class { 'concat::setup': }
class { 'mysql::server':
config_hash => {'bind_address' => '127.0.0.1'}
}
class { 'mysql::ruby': }
package { 'activerecord':
ensure => '2.3.5',
provider => 'gem',
}
class { 'puppet::master':
modulepath => '/vagrant/modules',
manifest => '/vagrant/manifests/site.pp',
storeconfigs => true,
storeconfigs_dbuser => 'dan',
storeconfigs_dbpassword => 'foo',
storeconfigs_dbadapter => 'mysql',
storeconfigs_dbserver => 'localhost',
storeconfigs_dbsocket => '/var/run/mysqld/mysqld.sock',
version => installed,
puppet_master_package => 'puppet',
package_provider => 'gem',
autosign => 'true',
certname => $clientcert,
}
}
node all {
#
# This manifest installs all of the nova
# components on one node.
class { 'mysql::server': }
if($::operatingsystem == 'Ubuntu') {
class { 'rabbitmq::repo::apt': }
}
class { 'nova::all':
db_password => 'password',
db_name => 'nova',
db_user => 'nova',
db_host => 'localhost',
rabbit_password => 'rabbitpassword',
rabbit_port => '5672',
rabbit_userid => 'rabbit_user',
rabbit_virtual_host => '/',
rabbit_host => 'localhost',
image_service => 'nova.image.glance.GlanceImageService',
glance_host => 'localhost',
glance_port => '9292',
libvirt_type => 'qemu',
}
}
node default {
fail("could not find a matching node entry for ${clientcert}")
}

19
ext/nova.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Extract creds
cd ~
sudo nova-manage project zipfile nova novaadmin
unzip nova.zip
source novarc
euca-add-keypair openstack > ~/cert.pem
# List
nova flavor-list
nova image-list
# Run instance
euca-run-instances ami-00000003 -k openstack -t m1.tiny
euca-describe-instances
echo 'log into your controller VM'
echo 'check the status of your VM with euca-describe-instances'
echo 'when it is in the running state, verify that you can login'
echo 'using ssh -i ~/cert.pem root@ip.address'

View File

@ -0,0 +1,16 @@
Puppet::Type.type(:nova_floating).provide(:default) do
desc "This is a default provider that does nothing. This allows us to install nova-manage on the same puppet run where we want to use it."
def create
return false
end
def destroy
return false
end
def exists?
fail('This is just the default provider for nova_floating, all it does is fail')
end
end

View File

@ -0,0 +1,26 @@
Puppet::Type.type(:nova_floating).provide(:nova_manage) do
desc "Manage nova floating"
defaultfor :kernel => 'Linux'
commands :nova_manage => 'nova-manage'
def exists?
begin
prefix=resource[:network].sub(/(^[0-9]*\.[0-9]*\.[0-9]*\.).*/, '\1')
return false if not nova_manage("floating", "list").match(/#{prefix}/)
rescue
return false
end
end
def create
nova_manage("floating", "create", resource[:network]) if exists? == false
end
def destroy
nova_manage("floating", "delete", resource[:network])
end
end

View File

@ -16,7 +16,7 @@ Puppet::Type.type(:nova_network).provide(:nova_manage) do
end
def create
nova_manage("network", "create", resource[:label], resource[:network], "1", resource[:available_ips])
nova_manage("network", "create", resource[:label], resource[:network], "1", resource[:available_ips], "--bridge=br100")
end
def destroy

View File

@ -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"]
}
}

19
manifests/cert.pp Normal file
View File

@ -0,0 +1,19 @@
class nova::cert( $enabled=false ) {
Exec['post-nova_config'] ~> Service['nova-cert']
Exec['nova-db-sync'] ~> Service['nova-cert']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
service { "nova-cert":
name => 'openstack-nova-cert',
ensure => $service_ensure,
enable => $enabled,
require => Package["openstack-nova"],
#subscribe => File["/etc/nova/nova.conf"]
}
}

View File

@ -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'],
}

View File

@ -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,

View File

@ -18,7 +18,9 @@ class nova::controller(
$flat_network_bridge_ip = '11.0.0.1',
$flat_network_bridge_netmask = '255.255.255.0',
$network_manager = undef,
$nova_network = '11.0.0.0/24',
$floating_network = '10.128.0.0/24',
$available_ips = '256',
$image_service = 'nova.image.glance.GlanceImageService',
@ -29,7 +31,9 @@ class nova::controller(
$admin_user = 'novaadmin',
$project_name = 'nova',
$verbose = undef
$verbose = undef,
$lock_path = undef
) {
@ -45,6 +49,8 @@ class nova::controller(
rabbit_userid => $rabbit_userid,
rabbit_password => $rabbit_password,
rabbit_virtual_host => $rabbit_virtual_host,
lock_path => $lock_path,
network_manager => $network_manager,
}
class { "nova::api": enabled => true }
@ -54,9 +60,21 @@ class nova::controller(
flat_network_bridge => $flat_network_bridge,
flat_network_bridge_ip => $flat_network_bridge_ip,
flat_network_bridge_netmask => $flat_network_bridge_netmask,
configure_bridge => false,
}
class { "nova::objectstore":
enabled => true,
}
class { "nova::cert":
enabled => true,
}
class { "nova::volume":
enabled => true,
}
class { "nova::objectstore": enabled => true }
class { "nova::scheduler": enabled => true }
nova::manage::admin { $admin_user: }
@ -69,4 +87,9 @@ class nova::controller(
available_ips => $available_ips,
require => Nova::Manage::Project[$project_name],
}
nova::manage::floating { "${project_name}-floating-${floating_network}":
network => $floating_network,
require => Nova::Manage::Project[$project_name],
}
}

View File

@ -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

View File

@ -23,14 +23,22 @@ class nova(
$verbose = false,
$nodaemon = false,
$periodic_interval = '60',
$report_interval = '10'
) {
$report_interval = '10',
$root_helper = $::nova::params::root_helper
) inherits 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 +49,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"]:
ensure => present,
require => Package["python-greenlet"]
}
package { $::nova::params::package_names:
ensure => present,
require => [Package["python-greenlet"], Anchor['nova-start']]
}
group { 'nova':
ensure => present,
system => true,
@ -59,13 +78,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":
@ -108,6 +122,7 @@ class nova(
# as well as controller.
'network_manager': value => $network_manager;
'use_deprecated_auth': value => true;
'root_helper': value => $root_helper;
}
exec { 'post-nova_config':
@ -121,6 +136,13 @@ class nova(
}
}
if $network_manager == 'nova.network.manager.FlatDHCPManager' {
nova_config {
'dhcpbridge': value => "/usr/bin/nova-dhcpbridge";
'dhcpbridge_flagfile': value => "/etc/nova/nova.conf";
}
}
if $image_service == 'nova.image.glance.GlanceImageService' {
nova_config {
'glance_api_servers': value => $glance_api_servers;
@ -128,5 +150,4 @@ class nova(
'glance_port': value => $glance_port;
}
}
}

View File

@ -0,0 +1,13 @@
define nova::manage::floating ( $network ) {
File['/etc/nova/nova.conf'] -> Nova_floating[$name]
Exec<| title == 'initial-db-sync' |> -> Nova_floating[$name]
nova_floating { $name:
ensure => present,
network => $network,
provider => 'nova_manage',
notify => Exec["nova-db-sync"],
}
}

View File

@ -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"]
}

View File

@ -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') }
}

View File

@ -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"]
}
}

46
manifests/params.pp Normal file
View File

@ -0,0 +1,46 @@
# 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'
# redhat specific config defaults
$root_helper = 'sudo nova-rootwrap'
}
'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'
# debian specific nova config
$root_helper = 'sudo'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} only support osfamily RedHat and Debian")
}
}
}

View File

@ -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,

View File

@ -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"]
}
}

32
manifests/volume.pp Normal file
View File

@ -0,0 +1,32 @@
class nova::volume( $enabled=false ) {
Exec['post-nova_config'] ~> Service['nova-volume']
Exec['nova-db-sync'] ~> Service['nova-volume']
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
exec {volumes:
command => 'dd if=/dev/zero of=/tmp/nova-volumes.img bs=1M seek=20k count=0 && /sbin/vgcreate nova-volumes `/sbin/losetup --show -f /tmp/nova-volumes.img`',
onlyif => 'test ! -e /tmp/nova-volumes.img',
path => ["/usr/bin", "/bin", "/usr/local/bin"],
before => Service['nova-volume'],
}
service { "nova-volume":
name => 'openstack-nova-volume',
ensure => $service_ensure,
enable => $enabled,
require => Package["openstack-nova"],
#subscribe => File["/etc/nova/nova.conf"]
}
service {'tgtd':
ensure => $service_ensure,
enable => $enabled,
require => Package["openstack-nova"],
}
}