From 53de0e725acd3b48d48947b9f3e2e9da99aeadd2 Mon Sep 17 00:00:00 2001 From: Roman Alekseenkov Date: Mon, 11 Mar 2013 16:39:49 -0700 Subject: [PATCH] OS compatibility checks. also, improved error reporting when a node is not found. --- .../site_openstack_compact_fordocs.pp | 28 +++++++++++ .../examples/site_openstack_ha_compact.pp | 28 +++++++++++ .../examples/site_openstack_ha_full.pp | 50 +++++++++++++++++++ .../examples/site_openstack_ha_minimal.pp | 36 ++++++++++--- .../examples/site_openstack_simple.pp | 8 +++ .../examples/site_openstack_single.pp | 6 ++- .../manifests/checksupported.pp | 26 ++++++++++ 7 files changed, 173 insertions(+), 9 deletions(-) create mode 100644 deployment/puppet/operatingsystem/manifests/checksupported.pp diff --git a/deployment/puppet/openstack/examples/site_openstack_compact_fordocs.pp b/deployment/puppet/openstack/examples/site_openstack_compact_fordocs.pp index 0506b42cee..3c07175686 100644 --- a/deployment/puppet/openstack/examples/site_openstack_compact_fordocs.pp +++ b/deployment/puppet/openstack/examples/site_openstack_compact_fordocs.pp @@ -77,6 +77,9 @@ $public_netmask = '255.255.255.0' $node = filter_nodes($nodes,'name',$::hostname) +if empty($node) { + fail("Node $::hostname is not defined in the hash structure") +} $internal_address = $node[0]['internal_address'] $public_address = $node[0]['public_address'] @@ -515,6 +518,11 @@ class compact_controller ( # Definition of the first OpenStack controller. node /fuel-controller-01/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -555,6 +563,11 @@ node /fuel-controller-01/ { # Definition of the second OpenStack controller. node /fuel-controller-02/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -595,6 +608,11 @@ node /fuel-controller-02/ { # Definition of the third OpenStack controller. node /fuel-controller-03/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -635,6 +653,11 @@ node /fuel-controller-03/ { # Definition of OpenStack compute nodes. node /fuel-compute-[\d+]/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -694,6 +717,11 @@ node /fuel-compute-[\d+]/ { # Definition of OpenStack Quantum node. node /fuel-quantum/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, diff --git a/deployment/puppet/openstack/examples/site_openstack_ha_compact.pp b/deployment/puppet/openstack/examples/site_openstack_ha_compact.pp index eea9a5f211..8590243489 100644 --- a/deployment/puppet/openstack/examples/site_openstack_ha_compact.pp +++ b/deployment/puppet/openstack/examples/site_openstack_ha_compact.pp @@ -77,6 +77,9 @@ $public_netmask = '255.255.255.0' $node = filter_nodes($nodes,'name',$::hostname) +if empty($node) { + fail("Node $::hostname is not defined in the hash structure") +} $internal_address = $node[0]['internal_address'] $public_address = $node[0]['public_address'] @@ -516,6 +519,11 @@ class compact_controller ( # Definition of the first OpenStack controller. node /fuel-controller-01/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -556,6 +564,11 @@ node /fuel-controller-01/ { # Definition of the second OpenStack controller. node /fuel-controller-02/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -596,6 +609,11 @@ node /fuel-controller-02/ { # Definition of the third OpenStack controller. node /fuel-controller-03/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -636,6 +654,11 @@ node /fuel-controller-03/ { # Definition of OpenStack compute nodes. node /fuel-compute-[\d+]/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -695,6 +718,11 @@ node /fuel-compute-[\d+]/ { # Definition of OpenStack Quantum node. node /fuel-quantum/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, diff --git a/deployment/puppet/openstack/examples/site_openstack_ha_full.pp b/deployment/puppet/openstack/examples/site_openstack_ha_full.pp index 34f5f49bd8..6e9a151531 100644 --- a/deployment/puppet/openstack/examples/site_openstack_ha_full.pp +++ b/deployment/puppet/openstack/examples/site_openstack_ha_full.pp @@ -114,6 +114,9 @@ $public_netmask = '255.255.255.0' $node = filter_nodes($nodes,'name',$::hostname) +if empty($node) { + fail("Node $::hostname is not defined in the hash structure") +} $internal_address = $node[0]['internal_address'] $public_address = $node[0]['public_address'] $controller_internal_addresses = nodes_to_hash(filter_nodes($nodes,'role','controller'),'name','internal_address') @@ -543,18 +546,40 @@ class ha_controller ( # Definition of OpenStack controller nodes. node /fuel-controller-01/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class { ha_controller: quantum_network_node => true } } + node /fuel-controller-02/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class { ha_controller: quantum_network_node => true } } + node /fuel-controller-03/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class { ha_controller: quantum_network_node => true } } # Definition of OpenStack compute nodes. node /fuel-compute-[\d+]/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -615,6 +640,11 @@ node /fuel-compute-[\d+]/ { # Definition of the first OpenStack Swift node. node /fuel-swift-01/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -644,6 +674,11 @@ node /fuel-swift-01/ { # Definition of the second OpenStack Swift node. node /fuel-swift-02/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -673,6 +708,11 @@ node /fuel-swift-02/ { # Definition of the third OpenStack Swift node. node /fuel-swift-03/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -702,6 +742,11 @@ node /fuel-swift-03/ { # Definition of OpenStack Swift proxy nodes. node /fuel-swiftproxy-[\d+]/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -728,6 +773,11 @@ node /fuel-swiftproxy-[\d+]/ { # Definition of OpenStack Quantum node. node /fuel-quantum/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, diff --git a/deployment/puppet/openstack/examples/site_openstack_ha_minimal.pp b/deployment/puppet/openstack/examples/site_openstack_ha_minimal.pp index 6b903b68e1..890b2e0fdf 100644 --- a/deployment/puppet/openstack/examples/site_openstack_ha_minimal.pp +++ b/deployment/puppet/openstack/examples/site_openstack_ha_minimal.pp @@ -77,6 +77,9 @@ $public_netmask = '255.255.255.0' $node = filter_nodes($nodes,'name',$::hostname) +if empty($node) { + fail("Node $::hostname is not defined in the hash structure") +} $internal_address = $node[0]['internal_address'] $public_address = $node[0]['public_address'] @@ -468,6 +471,11 @@ class compact_controller ( # Definition of OpenStack controller nodes. node /fuel-controller-01/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -487,7 +495,13 @@ node /fuel-controller-01/ { } class { compact_controller: } } + node /fuel-controller-02/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -507,7 +521,13 @@ node /fuel-controller-02/ { } class { compact_controller: } } + node /fuel-controller-03/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, @@ -530,13 +550,10 @@ node /fuel-controller-03/ { # Definition of OpenStack compute nodes. node /fuel-compute-[\d+]/ { - #class {'::node_netconfig': - # mgmt_ipaddr => $::internal_address, - # mgmt_netmask => $::internal_netmask, - # public_ipaddr => $::public_address, - # public_netmask => $::public_netmask, - # stage => 'netconfig', - #} + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } class {'nagios': proj_name => $proj_name, @@ -589,6 +606,11 @@ node /fuel-compute-[\d+]/ { # Definition of OpenStack Quantum node. node /fuel-quantum/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } + class {'::node_netconfig': mgmt_ipaddr => $::internal_address, mgmt_netmask => $::internal_netmask, diff --git a/deployment/puppet/openstack/examples/site_openstack_simple.pp b/deployment/puppet/openstack/examples/site_openstack_simple.pp index d52549cf2f..0d8d92b3f2 100644 --- a/deployment/puppet/openstack/examples/site_openstack_simple.pp +++ b/deployment/puppet/openstack/examples/site_openstack_simple.pp @@ -185,6 +185,10 @@ $horizon_use_ssl = false # Definition of OpenStack controller node. node /fuel-controller-[\d+]/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } class {'nagios': proj_name => $proj_name, @@ -249,6 +253,10 @@ node /fuel-controller-[\d+]/ { # Definition of OpenStack compute nodes. node /fuel-compute-[\d+]/ { + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } class {'nagios': proj_name => $proj_name, diff --git a/deployment/puppet/openstack/examples/site_openstack_single.pp b/deployment/puppet/openstack/examples/site_openstack_single.pp index dcfca99097..aa11ccc263 100644 --- a/deployment/puppet/openstack/examples/site_openstack_single.pp +++ b/deployment/puppet/openstack/examples/site_openstack_single.pp @@ -108,8 +108,10 @@ $openstack_version = { # Every node should be deployed as all-in-one openstack installations. node default { - - # include 'apache' + include stdlib + class { 'operatingsystem::checksupported': + stage => 'setup' + } class { 'openstack::all': public_address => $ipaddress_eth0, diff --git a/deployment/puppet/operatingsystem/manifests/checksupported.pp b/deployment/puppet/operatingsystem/manifests/checksupported.pp new file mode 100644 index 0000000000..dceb5a3044 --- /dev/null +++ b/deployment/puppet/operatingsystem/manifests/checksupported.pp @@ -0,0 +1,26 @@ +# +# This class is being used to check for compatibility with different operating systems +# If the operating system is not supported, it will fail early +# + +class operatingsystem::checksupported () { + + case $operatingsystem { + centos, redhat, ubuntu: {} + default: { + fail("Operating system $operatingsystem is not supported") + } + } + + case $architecture { + x86_64, amd64: {} + default: { + fail("Architecture $architecture is not supported. 64-bit architecture is required") + } + } + + notify { 'operatingsystem': + message => "Detected OS $operatingsystem, architecture $architecture" + } + +}