From e8bb35b01592aea72ec23117b2050a41c2e08e10 Mon Sep 17 00:00:00 2001 From: nitishkrishna Date: Wed, 15 Feb 2017 22:25:18 -0800 Subject: [PATCH] Closes-Bug: #1665162 - Puppet changes to prevent uninstall of ansible-provisioned bare metal compute A new flag is introduced to prevent any puppet uninstall of ansible-provisioned roles Uninstall compute code also fixed to remove duplicate declaration and other errors seen Change-Id: I32066ec93ba21c8feb9680ae251353e7811e1206 --- .../environment/modules/contrail/manifests/init.pp | 7 +++++++ .../environment/modules/contrail/manifests/params.pp | 1 + .../modules/contrail/manifests/profile/collector.pp | 3 ++- .../modules/contrail/manifests/profile/compute.pp | 3 ++- .../modules/contrail/manifests/profile/config.pp | 3 ++- .../modules/contrail/manifests/profile/controller.pp | 3 ++- .../modules/contrail/manifests/profile/database.pp | 3 ++- .../modules/contrail/manifests/profile/webui.pp | 3 ++- .../modules/contrail/manifests/uninstall_compute.pp | 10 ---------- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/contrail/environment/modules/contrail/manifests/init.pp b/contrail/environment/modules/contrail/manifests/init.pp index 6137bddd..4c6c9fac 100644 --- a/contrail/environment/modules/contrail/manifests/init.pp +++ b/contrail/environment/modules/contrail/manifests/init.pp @@ -588,6 +588,10 @@ # # [*ext_global_controller_port*] # external global controller port +# +# [*ansible_provision*] +# To detect if ansible provision is being done alongside puppet +# class contrail ( $host_ip = undef, $uuid = undef, @@ -604,6 +608,7 @@ $database_name_list = undef, $collector_name_list = undef, $openstack_name_list = undef, + $ansible_provision = false, $tsn_ip_list = '', $tsn_name_list = '', $internal_vip = '', @@ -962,6 +967,8 @@ # tsn Parameters tsn_ip_list => hiera(contrail::tsn::tsn_ip_list, hiera(contrail::params::tsn_ip_list, $tsn_ip_list)), tsn_name_list => hiera(contrail::tsn::tsn_name_list, hiera(contrail::params::tsn_name_list, $tsn_name_list)), + # Flag to check if ansible provision is being done alongside puppet + ansible_provision => hiera(contrail::ansible_provision, $ansible_provision), # Sequencing Parameters (Never come as json input, generated by SM). enable_provision_started => hiera(contrail::sequencing::enable_provision_started, hiera(contrail::params::enable_provision_started, $enable_provision_started)), enable_keepalived => hiera(contrail::sequencing::enable_keepalived, hiera(contrail::params::enable_keepalived, $enable_keepalived)), diff --git a/contrail/environment/modules/contrail/manifests/params.pp b/contrail/environment/modules/contrail/manifests/params.pp index 98d632f2..abc449bc 100644 --- a/contrail/environment/modules/contrail/manifests/params.pp +++ b/contrail/environment/modules/contrail/manifests/params.pp @@ -586,6 +586,7 @@ $database_name_list, $collector_name_list, $openstack_name_list, + $ansible_provision, $tsn_name_list, $internal_vip, $external_vip, diff --git a/contrail/environment/modules/contrail/manifests/profile/collector.pp b/contrail/environment/modules/contrail/manifests/profile/collector.pp index 15c70efa..8a2d2ff0 100644 --- a/contrail/environment/modules/contrail/manifests/profile/collector.pp +++ b/contrail/environment/modules/contrail/manifests/profile/collector.pp @@ -10,11 +10,12 @@ class contrail::profile::collector ( $enable_module = $::contrail::params::enable_collector, $is_there_roles_to_delete = $::contrail::params::is_there_roles_to_delete, + $ansible_provision = $::contrail::params::ansible_provision, $host_roles = $::contrail::params::host_roles ) { if ($enable_module and "collector" in $host_roles and $is_there_roles_to_delete == false) { contain ::contrail::collector - } elsif ((!("collector" in $host_roles)) and ($contrail_roles["collector"] == true)) { + } elsif ((!("collector" in $host_roles)) and ($contrail_roles["collector"] == true) and ($ansible_provision == false)) { notify { "uninstalling collector":; } contain ::contrail::uninstall_collector Notify["uninstalling collector"]->Class['::contrail::uninstall_collector'] diff --git a/contrail/environment/modules/contrail/manifests/profile/compute.pp b/contrail/environment/modules/contrail/manifests/profile/compute.pp index e524c727..3a8ac0b0 100644 --- a/contrail/environment/modules/contrail/manifests/profile/compute.pp +++ b/contrail/environment/modules/contrail/manifests/profile/compute.pp @@ -20,6 +20,7 @@ $openstack_debug = $::contrail::params::os_debug, $is_there_roles_to_delete = $::contrail::params::is_there_roles_to_delete, $openstack_rabbit_servers = $::contrail::params::openstack_rabbit_hosts, + $ansible_provision = $::contrail::params::ansible_provision, ) { if ($enable_module and "compute" in $host_roles and $is_there_roles_to_delete == false) { contain ::contrail::profile::nova::compute @@ -36,7 +37,7 @@ } class { '::ceilometer::agent::compute': } } - } elsif ((!("compute" in $host_roles)) and ($contrail_roles["compute"] == true)) { + } elsif ((!("compute" in $host_roles)) and ($contrail_roles["compute"] == true) and ($ansible_provision == false) ) { notify { "uninstalling compute":; } contain ::contrail::uninstall_compute Notify["uninstalling compute"]->Class['::contrail::uninstall_compute'] diff --git a/contrail/environment/modules/contrail/manifests/profile/config.pp b/contrail/environment/modules/contrail/manifests/profile/config.pp index fba7a3c1..5e3b8265 100644 --- a/contrail/environment/modules/contrail/manifests/profile/config.pp +++ b/contrail/environment/modules/contrail/manifests/profile/config.pp @@ -12,6 +12,7 @@ $is_there_roles_to_delete = $::contrail::params::is_there_roles_to_delete, $host_roles = $::contrail::params::host_roles, $manage_neutron = $::contrail::params::manage_neutron, + $ansible_provision = $::contrail::params::ansible_provision, ) { if ($enable_module and 'config' in $host_roles and $is_there_roles_to_delete == false) { @@ -21,7 +22,7 @@ contain ::contrail::profile::neutron_server Class['::contrail::config']->Class['::contrail::profile::neutron_server'] } - } elsif ((!('config' in $host_roles)) and ($contrail_roles['config'] == true)) { + } elsif ((!('config' in $host_roles)) and ($contrail_roles['config'] == true) and ($ansible_provision == false)) { notify { 'uninstalling config':; } contain ::contrail::uninstall_config Notify['uninstalling config']->Class['::contrail::uninstall_config'] diff --git a/contrail/environment/modules/contrail/manifests/profile/controller.pp b/contrail/environment/modules/contrail/manifests/profile/controller.pp index 7c1bb302..3179fce9 100644 --- a/contrail/environment/modules/contrail/manifests/profile/controller.pp +++ b/contrail/environment/modules/contrail/manifests/profile/controller.pp @@ -10,6 +10,7 @@ class contrail::profile::controller ( $enable_module = $::contrail::params::enable_control, $is_there_roles_to_delete = $::contrail::params::is_there_roles_to_delete, + $ansible_provision = $::contrail::params::ansible_provision, $host_roles = $::contrail::params::host_roles ) { @@ -17,7 +18,7 @@ contain ::contrail::control #contrail expects neutron server to run on controls include ::contrail::profile::neutron_server - } elsif ((!("control" in $host_roles)) and ($contrail_roles["control"] == true)) { + } elsif ((!("control" in $host_roles)) and ($contrail_roles["control"] == true) and ($ansible_provision == false)) { notify { "uninstalling control":; } contain ::contrail::uninstall_control Notify["uninstalling control"]->Class['::contrail::uninstall_control'] diff --git a/contrail/environment/modules/contrail/manifests/profile/database.pp b/contrail/environment/modules/contrail/manifests/profile/database.pp index 11f1af51..d4062dfc 100644 --- a/contrail/environment/modules/contrail/manifests/profile/database.pp +++ b/contrail/environment/modules/contrail/manifests/profile/database.pp @@ -15,6 +15,7 @@ $enable_module = $::contrail::params::enable_database, $host_roles = $::contrail::params::host_roles, $is_there_roles_to_delete = $::contrail::params::is_there_roles_to_delete, + $ansible_provision = $::contrail::params::ansible_provision, $enable_ceilometer = $::contrail::params::enable_ceilometer ) { if ($enable_module and "database" in $host_roles and $is_there_roles_to_delete == false) { @@ -23,7 +24,7 @@ contain ::contrail::profile::mongodb Class['::contrail::database']->Class['::contrail::profile::mongodb'] } - } elsif ((!("database" in $host_roles)) and ($contrail_roles["database"] == true)) { + } elsif ((!("database" in $host_roles)) and ($contrail_roles["database"] == true) and ($ansible_provision == false)) { contain ::contrail::uninstall_database notify { "uninstalling database":; } -> Class['::contrail::uninstall_database'] diff --git a/contrail/environment/modules/contrail/manifests/profile/webui.pp b/contrail/environment/modules/contrail/manifests/profile/webui.pp index d64ee091..6f1bdf77 100644 --- a/contrail/environment/modules/contrail/manifests/profile/webui.pp +++ b/contrail/environment/modules/contrail/manifests/profile/webui.pp @@ -10,12 +10,13 @@ class contrail::profile::webui ( $enable_module = $::contrail::params::enable_webui, $is_there_roles_to_delete = $::contrail::params::is_there_roles_to_delete, + $ansible_provision = $::contrail::params::ansible_provision, $host_roles = $::contrail::params::host_roles ) { if ($enable_module and 'webui' in $host_roles and $is_there_roles_to_delete == false) { contain ::contrail::webui - } elsif ((!('webui' in $host_roles)) and ($contrail_roles['webui'] == true)) { + } elsif ((!('webui' in $host_roles)) and ($contrail_roles['webui'] == true) and ($ansible_provision == false)) { notify { 'uninstalling webui':; } contain ::contrail::uninstall_webui Notify['uninstalling webui']->Class['::contrail::uninstall_webui'] diff --git a/contrail/environment/modules/contrail/manifests/uninstall_compute.pp b/contrail/environment/modules/contrail/manifests/uninstall_compute.pp index cbfb57d3..e5f8a338 100644 --- a/contrail/environment/modules/contrail/manifests/uninstall_compute.pp +++ b/contrail/environment/modules/contrail/manifests/uninstall_compute.pp @@ -87,11 +87,6 @@ ensure => stopped, } -> - file { '/etc/network/interfaces': - ensure => present, - source => '/etc/network/interfaces.orig', - } - -> # Main code for class starts here # Ensure all needed packages are latest package { [$vrouter_pkg, 'contrail-openstack-vrouter'] : @@ -129,16 +124,11 @@ apply => "immediately", subscribe => Class['::contrail::clear_compute'], timeout => 0, - } -> - class {'::contrail::do_reboot_server': - reboot_flag => 'uninstall_compute_reboot', } contain ::contrail::delete_vnc_config contain ::contrail::clear_compute - contain ::contrail::do_reboot_server if ($enable_lbaas == true) { - File['/etc/network/interfaces']-> package{['haproxy', 'iproute']: ensure => purged, notify => ['Exec[apt_auto_remove_compute]']