Skip to content

Commit

Permalink
handle centos/redhat packages according the os version, fixes #97
Browse files Browse the repository at this point in the history
  • Loading branch information
luxflux committed Jan 10, 2015
1 parent 7489a74 commit bae0c0e
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

This comment has been minimized.

Copy link
@retizu

retizu Oct 6, 2015

The EPEL repository has the package openvpn-auth-ldap for CentOS / RHEL, so this is not quite correct, but it's debatable if it's ok to install a repo on the fly for the user... anyway the code would be

#contains openvpn-auth-ldap lib
yumrepo { 'EPEL_repo':
    baseurl  => "https://dl.fedoraproject.org/pub/epel/${::operatingsystemmajrelease}/${::architecture}",
    descr    => 'Extra Packages for Enterprise Linux',
    enabled  => 1,
    gpgcheck => 0
}

This comment has been minimized.

Copy link
@elisiano

elisiano Oct 6, 2015

Contributor

I think it should be a parameter ($enable_epel ?).
Many companies do not allow servers to go out on the internet so they mirror everything locally.
Others might actually allow it and it's indeed enabled on some other modules.
Lastly there will be someone who is accessing yum behind a proxy.
The module should not be opinionated, but give the user the possibility to do things as they please.

This comment has been minimized.

Copy link
@luxflux

luxflux Oct 10, 2015

Author Contributor

Yeah, I would even just add a parameter like $epel_enabled which defaults to false and can be set to true. If it's true, the package will be installed. Managing package sources is not the job of this module.


}
'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 bae0c0e

Please sign in to comment.