-
Notifications
You must be signed in to change notification settings - Fork 21
/
common.pp
187 lines (172 loc) · 7.01 KB
/
common.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# == Class: contrail::common
#
# This class is used to configure software and services common
# to all contrail modules.
#
# === Parameters:
#
# [*host_mgmt_ip*]
# IP address of the server where contrail modules are being installed.
# if server has separate interfaces for management and control, this
# parameter should provide management interface IP address.
#
# [*contrail_repo_name*]
# Name of contrail repo being used to provision the contrail roles.
# Version of contrail software being used is specified here.
#
# [*contrail_repo_ip*]
# IP address of the server where contrail repo is mirrored. This is
# same as the cobbler address or server manager IP address (puppet master).
#
# [*contrail_repo_type*]
# Type of contrail repo (contrail-ubuntu-package or contrail-centos-package).
#
# [*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::common(
$host_mgmt_ip = $::contrail::params::host_ip,
$contrail_repo_name = $::contrail::params::contrail_repo_name,
$contrail_repo_ip = "puppet",
$contrail_repo_type = $::contrail::params::contrail_repo_type,
$contrail_upgrade = $::contrail::params::contrail_upgrade,
$contrail_logoutput = $::contrail::params::contrail_logoutput,
) {
include ::contrail::params
notify { "**** ${module_name} - host_mgmt_ip = ${host_mgmt_ip}": ; }
notify { "**** ${module_name} - contrail_repo_name = ${contrail_repo_name}": ; }
notify { "**** ${module_name} - contrail_repo_ip = ${contrail_repo_ip}": ; }
notify { "**** ${module_name} - contrail_repo_type = ${contrail_repo_type}": ; }
$contrail_group_details = {
'nova' => { gid => '499'},
'kvm' => { gid => '498'},
'libvirtd' => { gid => '497'}
}
$contrail_users_details = {
'nova' => { ensure => present, uid => '499', gid => '499', home => '/var/lib/nova' , managehome => true},
'libvirt-qemu' => { ensure => present, uid => '498', gid => '498', home => '/var/lib/libvirt', managehome => true},
'libvirt-dnsmasq' => { ensure => present, uid => '497', gid => '497', home => '/var/lib/libvirt/dnsmasq', managehome => true},
}
create_resources(group, $contrail_group_details)
create_resources(user, $contrail_users_details)
contrail::lib::contrail_upgrade{ 'contrail_upgrade':
contrail_upgrade => $contrail_upgrade,
contrail_logoutput => $contrail_logoutput
} ->
apt::pin { 'debian_repo_preferences':
priority => '-10',
originator => 'Debian'
} ->
# Resource declarations for class contrail::common
# macro to perform common functions
# Create repository config on target.
contrail::lib::contrail_setup_repo{ $contrail_repo_name:
contrail_repo_ip => $contrail_repo_ip,
contrail_logoutput => $contrail_logoutput
}
->
contrail::lib::contrail_install_repo{ $contrail_repo_type:
contrail_logoutput => $contrail_logoutput
}
->
contrail::lib::upgrade_kernel{ 'kernel_upgrade':
contrail_kernel_upgrade => $::contrail::params::kernel_upgrade,
contrail_logoutput => $contrail_logoutput
}
->
# Ensure /etc/hosts has an entry for self to map dns name to ip address
host { $::hostname :
ensure => present,
ip => $host_mgmt_ip
}
->
package { 'libssl0.9.8' : ensure => present,}
# Disable SELINUX on boot, if not already disabled.
if ($::operatingsystem == 'Centos' or $::operatingsystem == 'Fedora') {
exec { 'selinux-dis-1' :
command => "sed -i \'s/SELINUX=.*/SELINUX=disabled/g\' config",
cwd => '/etc/selinux',
onlyif => '[ -d /etc/selinux ]',
unless => "grep -qFx 'SELINUX=disabled' '/etc/selinux/config'",
provider => shell,
logoutput => $contrail_logoutput
}
# disable selinux runtime
exec { 'selinux-dis-2' :
command => 'setenforce 0 || true',
unless => 'getenforce | grep -qi disabled',
provider => shell,
logoutput => $contrail_logoutput
}
# Disable iptables
service { 'iptables' :
ensure => stopped,
enable => false,
}
}
if ($::operatingsystem == 'Ubuntu') {
# disable firewall
exec { 'disable-ufw' :
command => 'ufw disable',
unless => 'ufw status | grep -qi inactive',
provider => shell,
logoutput => $contrail_logoutput
}
# Create symbolic link to chkconfig. This does not exist on Ubuntu.
file { '/sbin/chkconfig':
ensure => link,
target => '/bin/true'
}
}
# Flush ip tables.
exec { 'iptables --flush': provider => shell, logoutput => $contrail_logoutput }
# Remove any core limit configured
if ($::operatingsystem == 'Centos' or $::operatingsystem == 'Fedora') {
exec { 'daemon-core-file-unlimited':
command => "sed -i \'/DAEMON_COREFILE_LIMIT=.*/d\' /etc/sysconfig/init; echo DAEMON_COREFILE_LIMIT=\"\'unlimited\'\" >> /etc/sysconfig/init",
unless => "grep -qx \"DAEMON_COREFILE_LIMIT='unlimited'\" /etc/sysconfig/init",
provider => shell,
logoutput => $contrail_logoutput
}
}
if ($::operatingsystem == 'Ubuntu') {
exec { 'core-file-unlimited' :
command => 'ulimit -c unlimited',
unless => 'ulimit -c | grep -qi unlimited',
provider => shell,
logoutput => $contrail_logoutput
}
}
sysctl::value { 'kernel.core_pattern':
value => '/var/crashes/core.%e.%p.%h.%t'
}
sysctl::value { 'net.ipv4.ip_forward':
value => '1'
}
sysctl::value { 'net.ipv4.ip_local_reserved_ports':
value => "35357,35358,33306,${::ipv4_reserved_ports}"
}
# Make sure our scripts directory is present
file { ['/var/log/mysql', '/var/crashes', '/etc/contrail', '/etc/contrail/contrail_setup_utils'] :
ensure => 'directory',
}
# Enable kernel core.
file { '/etc/contrail/contrail_setup_utils/enable_kernel_core.py':
ensure => present,
mode => '0755',
owner => root,
group => root,
source => "puppet:///modules/${module_name}/enable_kernel_core.py"
}
# enable kernel core , below python code has bug, for now ignore by executing echo regardless and thus returning true for cmd.
# need to revisit afterwards.
exec { 'enable-kernel-core' :
command => 'python /etc/contrail/contrail_setup_utils/enable_kernel_core.py; echo enable-kernel-core >> /etc/contrail/contrail_common_exec.out',
require => File['/etc/contrail/contrail_setup_utils/enable_kernel_core.py' ],
unless => 'grep -qx enable-kernel-core /etc/contrail/contrail_common_exec.out',
provider => shell,
logoutput => $contrail_logoutput
}
}