Skip to content

Commit 0f2c127

Browse files
authored
Merge pull request #296 from Dan33l/update-supported-os-params-pp
update supported OSes in params.pp
2 parents 9f3abf6 + cae1372 commit 0f2c127

15 files changed

+1637
-1607
lines changed

manifests/params.pp

Lines changed: 50 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -16,98 +16,71 @@
1616
#
1717
class openvpn::params {
1818

19-
case $::osfamily {
20-
'RedHat': {
19+
case $facts['os']['family'] {
20+
'RedHat': { # RedHat/CentOS
2121
$etc_directory = '/etc'
2222
$root_group = 'root'
2323
$group = 'nobody'
2424
$link_openssl_cnf = true
2525
$pam_module_path = '/usr/lib64/openvpn/plugin/lib/openvpn-auth-pam.so'
2626
$namespecific_rclink = false
27+
$default_easyrsa_ver = '3.0'
28+
$easyrsa_source = '/usr/share/easy-rsa/3'
2729

28-
# Redhat/Centos >= 7.0
29-
if(versioncmp($::operatingsystemrelease, '7.0') >= 0) and $::operatingsystem != 'Amazon' {
30-
$additional_packages = ['easy-rsa']
31-
$ldap_auth_plugin_location = undef
32-
$systemd = true
33-
$easyrsa_source = '/usr/share/easy-rsa/3'
34-
$default_easyrsa_ver = '3.0'
35-
# Redhat/Centos == 6.0
36-
} elsif(versioncmp($::operatingsystemrelease, '6.0') >= 0) and $::operatingsystem != 'Amazon' {
37-
$additional_packages = ['easy-rsa','openvpn-auth-ldap']
38-
$ldap_auth_plugin_location = '/usr/lib64/openvpn/plugin/lib/openvpn-auth-ldap.so'
39-
$systemd = false
40-
$easyrsa_source = '/usr/share/easy-rsa/3'
41-
$default_easyrsa_ver = '3.0'
42-
# Redhat/Centos < 6.0
43-
} else {
44-
$additional_packages = ['easy-rsa']
45-
$ldap_auth_plugin_location = undef
46-
$systemd = false
47-
$easyrsa_source = '/usr/share/easy-rsa/2.0'
48-
$default_easyrsa_ver = '2.0'
30+
case $facts['os']['release']['major'] {
31+
'7': {
32+
$additional_packages = ['easy-rsa']
33+
$ldap_auth_plugin_location = undef
34+
$systemd = true
35+
}
36+
'6': {
37+
$additional_packages = ['easy-rsa','openvpn-auth-ldap']
38+
$ldap_auth_plugin_location = '/usr/lib64/openvpn/plugin/lib/openvpn-auth-ldap.so'
39+
$systemd = false
40+
}
41+
default: {
42+
fail("unsupported OS ${facts['os']['name']} ${facts['os']['release']['major']}")
43+
}
4944
}
5045
}
5146
'Debian': { # Debian/Ubuntu
52-
$etc_directory = '/etc'
53-
$root_group = 'root'
54-
$group = 'nogroup'
55-
$link_openssl_cnf = true
56-
$namespecific_rclink = false
47+
$etc_directory = '/etc'
48+
$root_group = 'root'
49+
$group = 'nogroup'
50+
$link_openssl_cnf = true
51+
$namespecific_rclink = false
52+
$default_easyrsa_ver = '2.0'
53+
$additional_packages = ['easy-rsa','openvpn-auth-ldap']
54+
$easyrsa_source = '/usr/share/easy-rsa/'
55+
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
56+
$pam_module_path = '/usr/lib/openvpn/openvpn-plugin-auth-pam.so'
5757

58-
case $::operatingsystem {
58+
case $facts['os']['name'] {
5959
'Debian': {
60-
# Version > 8.0, jessie, stretch
61-
$default_easyrsa_ver = '2.0'
62-
if(versioncmp($::operatingsystemrelease, '8.0') >= 0) {
63-
$additional_packages = ['easy-rsa','openvpn-auth-ldap']
64-
$easyrsa_source = '/usr/share/easy-rsa/'
65-
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
66-
$pam_module_path = '/usr/lib/openvpn/openvpn-plugin-auth-pam.so'
67-
$systemd = true
68-
69-
# Version > 7.0, wheezy
70-
} elsif(versioncmp($::operatingsystemrelease, '7.0') >= 0) {
71-
$additional_packages = ['openvpn-auth-ldap']
72-
$easyrsa_source = '/usr/share/doc/openvpn/examples/easy-rsa/2.0'
73-
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
74-
$pam_module_path = '/usr/lib/openvpn/openvpn-auth-pam.so'
75-
$systemd = false
76-
} else {
77-
$additional_packages = undef
78-
$easyrsa_source = '/usr/share/doc/openvpn/examples/easy-rsa/2.0'
79-
$ldap_auth_plugin_location = undef
80-
$pam_module_path = '/usr/lib/openvpn/openvpn-auth-pam.so'
81-
$systemd = false
60+
case $facts['os']['release']['major'] {
61+
'8','9': {
62+
$systemd = true
63+
}
64+
default: {
65+
fail("unsupported OS ${facts['os']['name']} ${facts['os']['release']['major']}")
66+
}
8267
}
8368
}
8469
'Ubuntu': {
85-
$default_easyrsa_ver = '2.0'
86-
# Version > 15.04, vivid
87-
if(versioncmp($::operatingsystemrelease, '15.04') >= 0){
88-
$additional_packages = ['easy-rsa','openvpn-auth-ldap']
89-
$easyrsa_source = '/usr/share/easy-rsa/'
90-
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
91-
$pam_module_path = '/usr/lib/openvpn/openvpn-plugin-auth-pam.so'
92-
$systemd = true
93-
94-
# Version > 13.10, saucy
95-
} elsif(versioncmp($::operatingsystemrelease, '13.10') >= 0) {
96-
$additional_packages = ['easy-rsa','openvpn-auth-ldap']
97-
$easyrsa_source = '/usr/share/easy-rsa/'
98-
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
99-
$pam_module_path = '/usr/lib/openvpn/openvpn-plugin-auth-pam.so'
100-
$systemd = false
101-
} else {
102-
$additional_packages = undef
103-
$easyrsa_source = '/usr/share/doc/openvpn/examples/easy-rsa/2.0'
104-
$ldap_auth_plugin_location = undef
105-
$pam_module_path = '/usr/lib/openvpn/openvpn-auth-pam.so'
106-
$systemd = false
70+
case $facts['os']['release']['major'] {
71+
'16.04': {
72+
$systemd = true
73+
}
74+
'14.04': {
75+
$systemd = false
76+
}
77+
default: {
78+
fail("unsupported OS ${facts['os']['name']} ${facts['os']['release']['major']}")
79+
}
10780
}
10881
}
10982
default: {
110-
fail("Unsupported OS/Distribution ${::osfamily}/${::operatingsystem}")
83+
fail("unsupported OS ${facts['os']['name']} ${facts['os']['release']['major']}")
11184
}
11285
}
11386
}
@@ -119,30 +92,11 @@
11992
$easyrsa_source = '/usr/share/easy-rsa/'
12093
$group = 'nobody'
12194
$ldap_auth_plugin_location = undef # unsupported
95+
$pam_module_path = undef
12296
$link_openssl_cnf = true
12397
$systemd = true
12498
$namespecific_rclink = false
12599
}
126-
'Linux': {
127-
$default_easyrsa_ver = '2.0'
128-
case $::operatingsystem {
129-
'Amazon': {
130-
$etc_directory = '/etc'
131-
$root_group = 'root'
132-
$group = 'nobody'
133-
$additional_packages = ['easy-rsa']
134-
$easyrsa_source = '/usr/share/easy-rsa/2.0'
135-
$ldap_auth_plugin_location = undef
136-
$systemd = false
137-
$link_openssl_cnf = true
138-
$pam_module_path = '/usr/lib/openvpn/openvpn-auth-pam.so'
139-
$namespecific_rclink = false
140-
}
141-
default: {
142-
fail("Unsupported OS/Distribution ${::osfamily}/${::operatingsystem}")
143-
}
144-
}
145-
}
146100
'FreeBSD': {
147101
$etc_directory = '/usr/local/etc'
148102
$root_group = 'wheel'
@@ -156,9 +110,10 @@
156110
$systemd = false
157111
}
158112
default: {
159-
fail("Not supported OS family ${::osfamily}")
113+
fail("unsupported OS ${facts['os']['name']} ${facts['os']['release']['major']}")
160114
}
161115
}
116+
162117
$easyrsa_version = $facts['easyrsa'] ? {
163118
undef => $default_easyrsa_ver,
164119
default => $facts['easyrsa'],

manifests/server.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@
454454
Optional[String] $group = undef,
455455
Boolean $ipp = false,
456456
Boolean $duplicate_cn = false,
457-
String $local = $::ipaddress_eth0,
457+
String $local = $facts['ipaddress_eth0'],
458458
Variant[Boolean, String] $logfile = false,
459459
String $port = '1194',
460460
Optional[String] $portshare = undef,
Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
require 'spec_helper'
22

33
describe 'openvpn::config', type: :class do
4-
context 'on Debian based machines' do
5-
let(:facts) do
6-
{
7-
osfamily: 'Debian',
8-
operatingsystem: 'Debian',
9-
operatingsystemrelease: '7',
10-
concat_basedir: '/var/lib/puppet/concat'
11-
}
12-
end
4+
on_supported_os.each do |os, facts|
5+
context "on #{os}" do
6+
let(:facts) do
7+
facts
8+
end
139

14-
it { is_expected.to contain_concat('/etc/default/openvpn') }
15-
it { is_expected.to contain_concat__fragment('openvpn.default.header') }
10+
it { is_expected.to compile.with_all_deps }
1611

17-
context 'enabled autostart_all' do
18-
let(:pre_condition) { 'class { "openvpn": autostart_all => true }' }
12+
case facts[:os]['family']
13+
when 'Debian'
14+
context 'on Debian based machines' do
15+
it { is_expected.to contain_concat('/etc/default/openvpn') }
16+
it { is_expected.to contain_concat__fragment('openvpn.default.header') }
1917

20-
it {
21-
is_expected.to contain_concat__fragment('openvpn.default.header').with(
22-
'content' => %r{^AUTOSTART="all"}
23-
)
24-
}
25-
end
18+
context 'enabled autostart_all' do
19+
let(:pre_condition) { 'class { "openvpn": autostart_all => true }' }
20+
21+
it {
22+
is_expected.to contain_concat__fragment('openvpn.default.header').with(
23+
'content' => %r{^AUTOSTART="all"}
24+
)
25+
}
26+
end
2627

27-
context 'disabled autostart_all' do
28-
let(:pre_condition) { 'class { "openvpn": autostart_all => false }' }
28+
context 'disabled autostart_all' do
29+
let(:pre_condition) { 'class { "openvpn": autostart_all => false }' }
2930

30-
it {
31-
is_expected.to contain_concat__fragment('openvpn.default.header').with(
32-
'content' => %r{^AUTOSTART=""}
33-
)
34-
}
31+
it {
32+
is_expected.to contain_concat__fragment('openvpn.default.header').with(
33+
'content' => %r{^AUTOSTART=""}
34+
)
35+
}
36+
end
37+
end
38+
end
3539
end
3640
end
3741
end

0 commit comments

Comments
 (0)