-
Notifications
You must be signed in to change notification settings - Fork 21
/
uninstall_compute.pp
148 lines (142 loc) · 5.16 KB
/
uninstall_compute.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# This class is used to configure software and services required
# to run compute module (vrouter and agent) of contrail software suit.
#
# === Parameters:
#
# [*host_control_ip*]
# IP address of the server.
# If server has separate interfaces for management and control, this
# parameter should provide control interface IP address.
#
# [*openstack_ip*]
# IP address of server running openstack services. If the server has
# separate interfaces for management and control, this parameter
# should provide control interface IP address.
#
# [*contrail_logoutput*]
# Variable to specify if output of exec commands is to be logged or not.
# Values are true, false or on_failure
# (optional) - Defaults to false
#
class contrail::uninstall_compute (
$host_control_ip = $::contrail::params::host_ip,
$config_ip_to_use = $::contrail::params::config_ip_to_use,
$openstack_ip = $::contrail::params::openstack_ip_list[0],
$contrail_logoutput = $::contrail::params::contrail_logoutput,
$contrail_host_roles = $::contrail::params::host_roles,
$enable_lbaas = $::contrail::params::enable_lbaas,
$enable_dpdk = $::contrail::params::enable_dpdk,
) inherits ::contrail::params {
#Determine vrouter package to be installed based on the kernel
#TODO add DPDK support here
if ($enable_dpdk) {
mount { '/hugepages':
ensure => absent,
} ->
contrail::lib::augeas_conf_rm { "max_map_count_value_removed":
key => 'vm.max_map_count',
config_file => '/etc/sysctl.conf',
lens_to_use => 'properties.lns',
} ->
file_line {'fstab_hugetlbfs':
ensure => absent,
path => '/etc/fstab',
line => 'hugetlbfs /hugepages hugetlbfs defaults,pagesize=1G 0 0',
match => '^*hugetlbfs.*hugetlbfs.*$',
match_for_absence => true,
}
}
if ($operatingsystem == 'Ubuntu'){
if ($lsbdistrelease == '14.04') {
if ($kernelrelease == '3.13.0-85-generic') {
$vrouter_pkg = 'contrail-vrouter-3.13.0-85-generic'
} else {
$vrouter_pkg = 'contrail-vrouter-dkms'
}
} elsif ($lsbdistrelease == '12.04') {
if ($kernelrelease == '3.13.0-34-generic') {
$vrouter_pkg = 'contrail-vrouter-3.13.0-34-generic'
} else {
$vrouter_pkg = 'contrail-vrouter-dkms'
}
}
}
else {
$vrouter_pkg = 'contrail-vrouter'
}
# Debug Print all variable values
contrail::lib::report_status { 'uninstall_compute_started': } ->
notify {'host_control_ip = $host_control_ip':; } ->
notify {'openstack_ip = $openstack_ip':; } ->
notify {'config_ip_to_use = $config_ip_to_use':; }
->
class {'::contrail::delete_vnc_config':
config_ip_to_use => $config_ip_to_use,
host_control_ip => $host_control_ip,
keystone_admin_user => $keystone_admin_user,
keystone_admin_password => $keystone_admin_password,
keystone_admin_tenant => $keystone_admin_tenant,
openstack_ip => $openstack_ip,
contrail_router_type => "",
}
->
service { 'supervisor-vrouter' :
enable => false,
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'] :
ensure => purged,
notify => ['Exec[apt_auto_remove_compute]']
} ->
#The below way should be the ideal one,
#But when vrouter-agent starts , the actual physical interface is not removed,
#when vhost comes up.
#This results in non-reachablity
#package { 'contrail-openstack-vrouter' : ensure => latest, notify => 'Service[supervisor-vrouter]'}
exec { 'apt_auto_remove_compute':
command => 'apt-get autoremove -y --purge',
provider => shell,
logoutput => $contrail_logoutput
}
->
file { ['/etc/contrail/contrail_setup_utils/add_dev_tun_in_cgroup_device_acl.sh',
'/etc/contrail/vrouter_nodemgr_param',
'/etc/contrail/default_pmac',
'/etc/contrail/agent_param',
'/etc/contrail/contrail-vrouter-agent.conf',
'/etc/contrail/contrail-vrouter-nodemgr.conf',
]:
ensure => absent,
} ->
contrail::lib::report_status { 'uninstall_compute_completed': }
->
class {'::contrail::clear_compute':}
->
reboot { 'delete_compute':
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]']
} ->
Package[$vrouter_pkg]
}
}