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

Fix ensure with nonstandard versions #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions lib/facter/perl_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Facter.add(:perl) do
setcode do
perl = {}
current_info = Facter::Util::Resolution.exec('perl -v')
version = current_info.match(/v((\d+)\.(\d+)\.(\d*))/)
Facter.debug "Matching perl version as #{version}"
perl['version'] = version[1]
perl['majversion'] = version[2]
perl['minversion'] = version[3]
perl['subversion'] = version[4]
perl
end
end
45 changes: 17 additions & 28 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,27 @@
owner => root,
group => root,
mode => '0755',
}
file { '/etc/perl/CPAN/Config.pm':
ensure => present,
owner => root,
group => root,
mode => '0644',
content => template($::cpan::config_template),
require => File['/etc/perl/CPAN'],
before => File[$perl_config],
}
}
'RedHat': {
if versioncmp($::operatingsystemmajrelease, '6') >= 0 and $::operatingsystem != 'Fedora' {
file { '/usr/share/perl5/CPAN/Config.pm':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template($::cpan::config_template),
}
} else {
file { '/usr/lib/perl5/5.8.8/CPAN/Config.pm':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template($::cpan::config_template),
}
'DragonFly', 'FreeBSD': {
file { [ '/usr/local/perl5', "/usr/local/perl5/5.${::perl['minversion']}", "/usr/local/perl5/5.${::perl['minversion']}/CPAN" ]:
ensure => directory,
owner => 0,
group => 0,
mode => '0755',
before => File[$perl_config],
}
}
default: {
fail("Module ${module_name} is not supported on ${::osfamily} os.")
}
default: { }
}

file { $::cpan::perl_config:
ensure => present,
owner => $root_user,
group => $root_group,
mode => '0644',
content => template($::cpan::config_template),
}
}
}
11 changes: 7 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
$local_lib = $cpan::params::local_lib,
$config_template = $cpan::params::config_template,
$config_hash = $cpan::params::config_hash,
$root_user = $cpan::params::root_user,
$root_group = $cpan::params::root_group,
$package_ensure = $cpan::params::package_ensure,
$perl_config = $cpan::params::perl_config,
$ftp_proxy = $cpan::params::ftp_proxy,
$http_proxy = $cpan::params::http_proxy,
$urllist = $cpan::params::urllist,
Expand All @@ -62,9 +65,9 @@
}
validate_array($urllist)

anchor { 'cpan::begin': } ->
class { '::cpan::install': } ->
class { '::cpan::config': } ->
anchor { 'cpan::end': }
anchor { 'cpan::begin': }
-> class { '::cpan::install': }
-> class { '::cpan::config': }
-> anchor { 'cpan::end': }

}
55 changes: 34 additions & 21 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
#
class cpan::params {

$manage_config = true
$installdirs = 'site'
$local_lib = false
$config_template = 'cpan/cpan.conf.erb'
$config_hash = { 'build_requires_install_policy' => 'no' }
$package_ensure = 'present'
$common_package = ['gcc','make']
$ftp_proxy = undef
$http_proxy = undef
$urllist = []
$manage_config = true
$installdirs = 'site'
$local_lib = false
$config_template = 'cpan/cpan.conf.erb'
$config_hash = { 'build_requires_install_policy' => 'no' }
$package_ensure = 'present'
$common_package = ['gcc','make']
$ftp_proxy = undef
$http_proxy = undef
$urllist = []

unless $installdirs =~ /^(perl|site|vendor)$/ {
fail('installdirs must be one of {perl,site,vendor}')
Expand All @@ -27,28 +27,41 @@
case $::osfamily {
'Debian': {
$common_os_package = ['perl-modules']
$perl_config = '/etc/perl/CPAN/Config.pm'
$root_user = 'root'
$root_group = 'root'
if $local_lib {
$local_lib_package = ['liblocal-lib-perl']
$local_lib_package = ['liblocal-lib-perl']
} else {
$local_lib_package = []
$local_lib_package = []
}
}
'RedHat': {
$common_os_package = ['perl-CPAN']

if $local_lib {
if ($::operatingsystem == 'RedHat' and versioncmp($::operatingsystemmajrelease, '6') >= 0) {
$local_lib_package = ['perl-local-lib']
} elsif ($::operatingsystem == 'Fedora' and versioncmp($::operatingsystemmajrelease, '16') >=0) {
$local_lib_package = ['perl-local-lib']
case $::operatingsystemmajrelease {
5, 6: {
$local_lib_package = ['perl-local-lib']
$perl_config = '/usr/share/perl5/CPAN/Config.pm'
$root_user = 'root'
$root_group = 'root'
}
} else {
$local_lib_package = []
7: {
$root_user = 'root'
$root_group = 'wheel'
}
default: { }
}
}
'DragonFly', 'FreeBSD': {
$perl_config = "/usr/local/perl5/5.${::perl['minversion']}/CPAN/Config.pm"
$root_user = 'root'
$root_group = 'wheel'
$local_lib_package = []
$common_os_package = []
}
default: {
fail("Module ${module_name} is not supported on ${::osfamily}")
}
}
$package_name = concat($common_package,$common_os_package,$local_lib_package )
$package_name = concat($common_package,$common_os_package,$local_lib_package)
}
2 changes: 1 addition & 1 deletion spec/classes/cpan_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
describe 'cpan::config on RedHat and operatingsystemrelease 7' do
let(:facts) { super().merge(:osfamily => 'RedHat', :operatingsystemmajrelease => '7') }
it { should contain_file('/usr/share/perl5/CPAN/Config.pm').with_owner('root') }
it { should contain_file('/usr/share/perl5/CPAN/Config.pm').with_group('root') }
it { should contain_file('/usr/share/perl5/CPAN/Config.pm').with_group('wheel') }
it { should contain_file('/usr/share/perl5/CPAN/Config.pm').with_mode('0644') }
end

Expand Down