Skip to content

Commit

Permalink
handle centos/redhat packages according the os version, fixes voxpupu…
Browse files Browse the repository at this point in the history
  • Loading branch information
luxflux authored and typhonius committed Jan 11, 2015
1 parent 0ab2a6d commit a4eb322
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
21 changes: 10 additions & 11 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@

case $::osfamily {
'RedHat': {
# Redhat/Centos >= 6
if($::operatingsystemmajrelease >= 6) {
# http://docs.puppetlabs.com/references/latest/function.html#versioncmp
if(versioncmp($::operatingsystemrelease, '6.4') < 0) { # Version < 6.4
$easyrsa_source = '/usr/share/openvpn/easy-rsa/2.0'
} else { # Version >= 6.4
$additional_packages = ['easy-rsa', 'openvpn-auth-ldap']
$easyrsa_source = '/usr/share/easy-rsa/2.0'
$ldap_auth_plugin_location = '/usr/lib64/openvpn/plugin/lib/openvpn-auth-ldap.so'
}
} else { # Redhat/CentOS < 6
# Redhat/Centos >= 6.4
if(versioncmp($::operatingsystemrelease, '6.4') >= 0) {
$additional_packages = ['easy-rsa']
$easyrsa_source = '/usr/share/easy-rsa/2.0'

# Redhat/Centos < 6.4
} else {
$easyrsa_source = '/usr/share/doc/openvpn/examples/easy-rsa/2.0'
}

$ldap_auth_plugin_location = undef # no ldap plugin on redhat/centos

}
'Debian': { # Debian/Ubuntu
case $::lsbdistid {
Expand Down
30 changes: 30 additions & 0 deletions spec/classes/openvpn_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
describe 'openvpn::install', :type => :class do
let(:osfamily) { 'Debian' }
let(:operatingsystemmajrelease) { nil }
let(:operatingsystemrelease) { nil }
let(:lsbdistid) { 'Ubuntu' }
let(:lsbdistrelease) { '13.10' }
let(:facts) do
{
:osfamily => osfamily,
:operatingsystemmajrelease => operatingsystemmajrelease,
:operatingsystemrelease => operatingsystemrelease,
:lsbdistid => lsbdistid,
:lsbdistrelease => lsbdistrelease,
}
Expand Down Expand Up @@ -43,5 +45,33 @@
it { should contain_package('easy-rsa') }
end
end

context 'redhat/centos' do
let(:osfamily) { 'RedHat' }

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

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

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

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

0 comments on commit a4eb322

Please sign in to comment.