Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for amazon OS and systems without lsb-release #134

Merged
merged 9 commits into from
Mar 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## Next version

* Support for systems without `lsb-release` package ([#134](https://github.com/luxflux/puppet-openvpn/pull/134))

## 2.7.1

* Fix server in client mode ([#137](https://github.com/luxflux/puppet-openvpn/pull/137))

## 2.7.0
Expand Down
46 changes: 27 additions & 19 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
# limitations under the License.
#
class openvpn::params {

$group = $::osfamily ? {
'RedHat' => 'nobody',
default => 'nogroup'
}

case $::osfamily {
'RedHat': {
$group = 'nobody'
$link_openssl_cnf = true

# Redhat/Centos >= 7.0
if(versioncmp($::operatingsystemrelease, '7.0') >= 0) {
$additional_packages = ['easy-rsa']
Expand All @@ -49,16 +46,19 @@
$ldap_auth_plugin_location = undef # no ldap plugin on redhat/centos
}
'Debian': { # Debian/Ubuntu
case $::lsbdistid {
$group = 'nogroup'
$link_openssl_cnf = true

case $::operatingsystem {
'Debian': {
# Version > 8.0.0, jessie
if(versioncmp($::lsbdistrelease, '8.0.0') >= 0) {
# Version > 8.0, jessie
if(versioncmp($::operatingsystemrelease, '8.0') >= 0) {
$additional_packages = ['easy-rsa', 'openvpn-auth-ldap']
$easyrsa_source = '/usr/share/easy-rsa/'
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'

# Version > 7.0.0, wheezy
} elsif(versioncmp($::lsbdistrelease, '7.0.0') >= 0) {
# Version > 7.0, wheezy
} elsif(versioncmp($::operatingsystemrelease, '7.0') >= 0) {
$additional_packages = ['openvpn-auth-ldap']
$easyrsa_source = '/usr/share/doc/openvpn/examples/easy-rsa/2.0'
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
Expand All @@ -68,7 +68,7 @@
}
'Ubuntu': {
# Version > 13.10, saucy
if(versioncmp($::lsbdistrelease, '13.10') >= 0) {
if(versioncmp($::operatingsystemrelease, '13.10') >= 0) {
$additional_packages = ['easy-rsa', 'openvpn-auth-ldap']
$easyrsa_source = '/usr/share/easy-rsa/'
$ldap_auth_plugin_location = '/usr/lib/openvpn/openvpn-auth-ldap.so'
Expand All @@ -77,20 +77,28 @@
}
}
default: {
fail("Not supported OS / Distribution: ${::osfamily}/${::lsbdistid}")
fail("Not supported OS / Distribution: ${::osfamily}/${::operatingsystem}")
}
}

$systemd = false
}
'Linux': {
case $::operatingsystem {
'Amazon': {
$group = 'nobody'
$additional_packages = ['easy-rsa']
$easyrsa_source = '/usr/share/easy-rsa/2.0'
$systemd = false
$link_openssl_cnf = true
}
default: {
fail("Not supported OS / Distribution: ${::osfamily}/${::operatingsystem}")
}
}
}
default: {
fail("Not supported OS family ${::osfamily}")
}
}

$link_openssl_cnf = $::osfamily ? {
/(Debian|RedHat)/ => true,
default => false
}

}
10 changes: 5 additions & 5 deletions spec/classes/openvpn_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
context 'non-systemd systems' do
let(:facts) { {
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

it { should create_class('openvpn') }
Expand All @@ -16,8 +16,8 @@

context 'systemd systems' do
let(:facts) { {
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'RedHat',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
} }

Expand Down
25 changes: 17 additions & 8 deletions spec/classes/openvpn_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
let(:osfamily) { 'Debian' }
let(:operatingsystemmajrelease) { nil }
let(:operatingsystemrelease) { nil }
let(:lsbdistid) { 'Ubuntu' }
let(:lsbdistrelease) { '13.10' }
let(:operatingsystem) { 'Ubuntu' }
let(:operatingsystemrelease) { '13.10' }
let(:facts) do
{
:osfamily => osfamily,
:operatingsystemmajrelease => operatingsystemmajrelease,
:operatingsystemrelease => operatingsystemrelease,
:lsbdistid => lsbdistid,
:lsbdistrelease => lsbdistrelease,
:operatingsystem => operatingsystem,
:operatingsystemrelease => operatingsystemrelease,
}
end

Expand All @@ -25,22 +25,22 @@
describe 'installed packages' do
context 'debian' do
let(:osfamily) { 'Debian' }
let(:lsbdistid) { 'Debian' }
let(:operatingsystem) { 'Debian' }

context 'squeeze' do
let(:lsbdistrelease) { '6.5' }
let(:operatingsystemrelease) { '6.5' }
it { should_not contain_package('openvpn-auth-ldap') }
it { should_not contain_package('easy-rsa') }
end

context 'wheezy' do
let(:lsbdistrelease) { '7.4' }
let(:operatingsystemrelease) { '7.4' }
it { should contain_package('openvpn-auth-ldap') }
it { should_not contain_package('easy-rsa') }
end

context 'jessie' do
let(:lsbdistrelease) { '8.0.0' }
let(:operatingsystemrelease) { '8.0.0' }
it { should contain_package('openvpn-auth-ldap') }
it { should contain_package('easy-rsa') }
end
Expand Down Expand Up @@ -73,5 +73,14 @@
it { should contain_package('easy-rsa') }
end
end

context 'Amazon' do
let(:osfamily) { 'Linux' }
let(:operatingsystem) { 'Amazon' }
let(:operatingsystemrelease) { nil }

it { should_not contain_package('openvpn-auth-ldap') }
it { should contain_package('easy-rsa') }
end
end
end
28 changes: 14 additions & 14 deletions spec/defines/openvpn_ca_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

let(:facts) { {
:ipaddress_eth0 => '1.2.3.4',
:network_eth0 => '1.2.3.0',
:netmask_eth0 => '255.255.255.0',
:network_eth0 => '1.2.3.0',
:netmask_eth0 => '255.255.255.0',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

context "creating a server with the minimum parameters" do
Expand Down Expand Up @@ -73,8 +73,8 @@
:netmask_eth0 => '255.255.255.0',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

it { should contain_file('/etc/openvpn/test_server/easy-rsa/vars').with_content(/^export CA_EXPIRE=365$/) }
Expand Down Expand Up @@ -148,7 +148,7 @@
'email' => '[email protected]'
} }

let(:facts) { { :osfamily => 'Debian', :lsbdistid => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }
let(:facts) { { :osfamily => 'Debian', :operatingsystem => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }

shared_examples_for 'a newer version than wheezy' do
it { should contain_package('easy-rsa').with('ensure' => 'present') }
Expand All @@ -158,24 +158,24 @@
end
context "when jessie/sid" do
before do
facts[:lsbdistid] = 'Debian'
facts[:lsbdistrelease] = '8.0.1'
facts[:operatingsystem] = 'Debian'
facts[:operatingsystemrelease] = '8.0.1'
end
it_behaves_like 'a newer version than wheezy'
end

context 'when ubuntu 13.10' do
before do
facts[:lsbdistid] = 'Ubuntu'
facts[:lsbdistrelease] = '13.10'
facts[:operatingsystem] = 'Ubuntu'
facts[:operatingsystemrelease] = '13.10'
end
it_behaves_like 'a newer version than wheezy'
end

context 'when ubuntu 14.04' do
before do
facts[:lsbdistid] = 'Ubuntu'
facts[:lsbdistrelease] = '14.04'
facts[:operatingsystem] = 'Ubuntu'
facts[:operatingsystemrelease] = '14.04'
end
it_behaves_like 'a newer version than wheezy'
end
Expand Down
16 changes: 8 additions & 8 deletions spec/defines/openvpn_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
let(:title) { 'test_client' }
let(:params) { { 'server' => 'test_server' } }
let(:facts) { {
:fqdn => 'somehost',
:fqdn => 'somehost',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }
let(:pre_condition) do
'openvpn::server { "test_server":
Expand Down Expand Up @@ -89,11 +89,11 @@
'rcvbuf' => 393215,
} }
let(:facts) { {
:fqdn => 'somehost',
:fqdn => 'somehost',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

it { should contain_file('/etc/openvpn/test_server/download-configs/test_client/test_client.conf').with_content(/^client$/)}
Expand Down
8 changes: 4 additions & 4 deletions spec/defines/openvpn_client_specific_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
let(:title) { 'test_client' }
let(:params) { { 'server' => 'test_server' } }
let(:facts) { {
:fqdn => 'somehost',
:fqdn => 'somehost',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }
let(:pre_condition) do
[
Expand Down
8 changes: 4 additions & 4 deletions spec/defines/openvpn_revoke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
let(:title) { 'test_client' }
let(:params) { { 'server' => 'test_server' } }
let(:facts) { {
:fqdn => 'somehost',
:fqdn => 'somehost',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }
let(:pre_condition) do
[
Expand Down
24 changes: 12 additions & 12 deletions spec/defines/openvpn_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

let(:facts) { {
:ipaddress_eth0 => '1.2.3.4',
:network_eth0 => '1.2.3.0',
:netmask_eth0 => '255.255.255.0',
:network_eth0 => '1.2.3.0',
:netmask_eth0 => '255.255.255.0',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

context 'creating a server without any parameter' do
Expand Down Expand Up @@ -155,8 +155,8 @@
:netmask_eth0 => '255.255.255.0',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^mode\s+server$/) }
Expand Down Expand Up @@ -235,8 +235,8 @@
:netmask_eth0 => '255.255.255.0',
:concat_basedir => '/var/lib/puppet/concat',
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistrelease => '12.04',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '12.04',
} }

it { should contain_file('/etc/openvpn/test_client.conf').with_content(/^client$/) }
Expand Down Expand Up @@ -334,7 +334,7 @@
'email' => '[email protected]'
} }

let(:facts) { { :osfamily => 'Debian', :lsbdistid => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }
let(:facts) { { :osfamily => 'Debian', :operatingsystem => 'Debian', :concat_basedir => '/var/lib/puppet/concat' } }

# Configure to start vpn session
it { should contain_concat__fragment('openvpn.default.autostart.test_server').with(
Expand All @@ -348,8 +348,8 @@
context 'ldap' do
before do
facts[:osfamily] = 'Debian'
facts[:lsbdistid] = 'Debian'
facts[:lsbdistrelease] = '8.0.0'
facts[:operatingsystem] = 'Debian'
facts[:operatingsystemrelease] = '8.0.0'
end
let(:params) { {
'country' => 'CO',
Expand Down