From b8c7b9a5563b2c681f58b9deae700411bb0f2ec5 Mon Sep 17 00:00:00 2001 From: Wong Hoi Sing Edison Date: Wed, 20 Jun 2012 11:41:23 +0800 Subject: [PATCH] Add optional auto_assign_floating_ip parameter. --- examples/site.pp | 64 ++++++++++++++++++++++------------------- manifests/all.pp | 46 +++++++++++++++++------------ manifests/controller.pp | 8 ++++++ 3 files changed, 69 insertions(+), 49 deletions(-) diff --git a/examples/site.pp b/examples/site.pp index 2f39c3e..34bbdaf 100644 --- a/examples/site.pp +++ b/examples/site.pp @@ -16,25 +16,27 @@ file { '/tmp/test_nova.sh': # environments # assumes that eth0 is the public interface -$public_interface = 'eth0' +$public_interface = 'eth0' # assumes that eth1 is the interface that will be used for the vm network # this configuration assumes this interface is active but does not have an # ip address allocated to it. -$private_interface = 'eth1' +$private_interface = 'eth1' # credentials -$admin_email = 'root@localhost' -$admin_password = 'keystone_admin' -$keystone_db_password = 'keystone_db_pass' -$keystone_admin_token = 'keystone_admin_token' -$nova_db_password = 'nova_pass' -$nova_user_password = 'nova_pass' -$glance_db_password = 'glance_pass' -$glance_user_password = 'glance_pass' -$rabbit_password = 'openstack_rabbit_password' -$rabbit_user = 'openstack_rabbit_user' -$fixed_network_range = '10.0.0.0/24' +$admin_email = 'root@localhost' +$admin_password = 'keystone_admin' +$keystone_db_password = 'keystone_db_pass' +$keystone_admin_token = 'keystone_admin_token' +$nova_db_password = 'nova_pass' +$nova_user_password = 'nova_pass' +$glance_db_password = 'glance_pass' +$glance_user_password = 'glance_pass' +$rabbit_password = 'openstack_rabbit_password' +$rabbit_user = 'openstack_rabbit_user' +$fixed_network_range = '10.0.0.0/24' # switch this to true to have all service log at verbose -$verbose = 'false' +$verbose = 'false' +# by default it does not enable atomatically adding floating IPs +$auto_assign_floating_ip = 'false' #### end shared variables ################# @@ -44,22 +46,23 @@ $verbose = 'false' node /openstack_all/ { class { 'openstack::all': - public_address => $ipaddress_eth0, - public_interface => $public_interface, - private_interface => $private_interface, - admin_email => $admin_email, - admin_password => $admin_password, - keystone_db_password => $keystone_db_password, - keystone_admin_token => $keystone_admin_token, - nova_db_password => $nova_db_password, - nova_user_password => $nova_user_password, - glance_db_password => $glance_db_password, - glance_user_password => $glance_user_password, - rabbit_password => $rabbit_password, - rabbit_user => $rabbit_user, - libvirt_type => 'kvm', - fixed_range => $fixed_network_range, - verbose => $verbose, + public_address => $ipaddress_eth0, + public_interface => $public_interface, + private_interface => $private_interface, + admin_email => $admin_email, + admin_password => $admin_password, + keystone_db_password => $keystone_db_password, + keystone_admin_token => $keystone_admin_token, + nova_db_password => $nova_db_password, + nova_user_password => $nova_user_password, + glance_db_password => $glance_db_password, + glance_user_password => $glance_user_password, + rabbit_password => $rabbit_password, + rabbit_user => $rabbit_user, + libvirt_type => 'kvm', + fixed_range => $fixed_network_range, + verbose => $verbose, + auto_assign_floating_ip => $auto_assign_floating_ip, } class { 'openstack::auth_file': @@ -96,6 +99,7 @@ node /openstack_controller/ { # by default is assumes flat dhcp networking mode network_manager => 'nova.network.manager.FlatDHCPManager', verbose => $verbose, + auto_assign_floating_ip => $auto_assign_floating_ip, mysql_root_password => $mysql_root_password, admin_email => $admin_email, admin_password => $admin_password, diff --git a/manifests/all.pp b/manifests/all.pp index 2a11148..771e998 100644 --- a/manifests/all.pp +++ b/manifests/all.pp @@ -15,6 +15,9 @@ # [fixed_range] The fixed private ip range to be created for the private VM network. Optional. Defaults to '10.0.0.0/24'. # [network_manager] The network manager to use for the nova network service. # Optional. Defaults to 'nova.network.manager.FlatDHCPManager'. +# [auto_assign_floating_ip] Rather configured to automatically allocate and +# assign a floating IP address to virtual instances when they are launched. +# Defaults to false. # [network_config] Used to specify network manager specific parameters .Optional. Defualts to {}. # [mysql_root_password] The root password to set for the mysql database. Optional. Defaults to sql_pass'. # [rabbit_password] The password to use for the rabbitmq user. Optional. Defaults to rabbit_pw' @@ -53,28 +56,29 @@ class openstack::all( $public_address, $public_interface, $private_interface, - $floating_range = false, - $fixed_range = '10.0.0.0/24', - $network_manager = 'nova.network.manager.FlatDHCPManager', - $network_config = {}, + $floating_range = false, + $fixed_range = '10.0.0.0/24', + $network_manager = 'nova.network.manager.FlatDHCPManager', + $network_config = {}, # middleware credentials - $mysql_root_password = 'sql_pass', - $rabbit_password = 'rabbit_pw', - $rabbit_user = 'nova', + $mysql_root_password = 'sql_pass', + $rabbit_password = 'rabbit_pw', + $rabbit_user = 'nova', # opestack credentials - $admin_email = 'someuser@some_fake_email_address.foo', - $admin_password = 'ChangeMe', - $keystone_db_password = 'keystone_pass', - $keystone_admin_token = 'keystone_admin_token', - $nova_db_password = 'nova_pass', - $nova_user_password = 'nova_pass', - $glance_db_password = 'glance_pass', - $glance_user_password = 'glance_pass', + $admin_email = 'someuser@some_fake_email_address.foo', + $admin_password = 'ChangeMe', + $keystone_db_password = 'keystone_pass', + $keystone_admin_token = 'keystone_admin_token', + $nova_db_password = 'nova_pass', + $nova_user_password = 'nova_pass', + $glance_db_password = 'glance_pass', + $glance_user_password = 'glance_pass', # config - $verbose = false, - $purge_nova_config = true, - $libvirt_type = 'kvm', - $nova_volume = 'nova-volumes' + $verbose = false, + $auto_assign_floating_ip = false, + $purge_nova_config = true, + $libvirt_type = 'kvm', + $nova_volume = 'nova-volumes' ) { @@ -211,6 +215,10 @@ class openstack::all( create_networks => true, } + if $auto_assign_floating_ip { + nova_config { 'auto_assign_floating_ip': value => 'True'; } + } + # a bunch of nova services that require no configuration class { [ 'nova::scheduler', diff --git a/manifests/controller.pp b/manifests/controller.pp index 9c7d733..793eb00 100644 --- a/manifests/controller.pp +++ b/manifests/controller.pp @@ -26,6 +26,9 @@ # [num_networks] Number of networks that fixed range should be split into. # [multi_host] Rather node should support multi-host networking mode for HA. # Optional. Defaults to false. +# [auto_assign_floating_ip] Rather configured to automatically allocate and +# assign a floating IP address to virtual instances when they are launched. +# Defaults to false. # [network_config] Hash that can be used to pass implementation specifc # network settings. Optioal. Defaults to {} # [verbose] Rahter to log services at verbose. @@ -68,6 +71,7 @@ class openstack::controller( $create_networks = true, $num_networks = 1, $multi_host = false, + $auto_assign_floating_ip = false, # TODO need to reconsider this design... # this is where the config options that are specific to the network # types go. I am not extremely happy with this.... @@ -269,6 +273,10 @@ class openstack::controller( install_service => $enable_network_service, } + if $auto_assign_floating_ip { + nova_config { 'auto_assign_floating_ip': value => 'True'; } + } + ######## Horizon ######## class { 'memcached':