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

Add parameter clean_old_kernels #20

Merged
merged 1 commit into from
Nov 8, 2016
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ class { 'yum':
gpgcheck => false|true,
installonly_limit => number,
keep_kernel_devel => false|true,
clean_old_kernels => false|true,
}
```

If `installonly_limit` is changed, purging of old kernel packages is triggered.
If `installonly_limit` is changed, purging of old kernel packages is triggered if `clean_old_kernels` is `true`.

### yum::config

Expand Down
13 changes: 10 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
$obsoletes = $yum::params::obsoletes,
$gpgcheck = $yum::params::gpgcheck,
$installonly_limit = $yum::params::installonly_limit,
$keep_kernel_devel = $yum::params::keep_kernel_devel
$keep_kernel_devel = $yum::params::keep_kernel_devel,
$clean_old_kernels = $yum::params::clean_old_kernels
) inherits yum::params {

validate_bool($keepcache, $exactarch, $obsoletes, $gpgcheck)
validate_bool($keep_kernel_devel)
validate_bool($keep_kernel_devel, $clean_old_kernels)

unless is_integer($installonly_limit) {
validate_string($installonly_limit)
Expand All @@ -42,6 +43,12 @@
validate_string($debuglevel)
}

if $clean_old_kernels {
$_installonly_limit_notify = Exec['package-cleanup_oldkernels']
} else {
$_installonly_limit_notify = undef
}

# configure Yum
yum::config { 'keepcache':
ensure => bool2num($keepcache),
Expand All @@ -65,7 +72,7 @@

yum::config { 'installonly_limit':
ensure => $installonly_limit,
notify => Exec['package-cleanup_oldkernels'],
notify => $_installonly_limit_notify,
}

# cleanup old kernels
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$gpgcheck = true
$installonly_limit = 5
$keep_kernel_devel = false
$clean_old_kernels = true
}
default: {
fail("${::operatingsystem} not supported")
Expand Down
12 changes: 12 additions & 0 deletions spec/classes/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
it { is_expected.to compile.with_all_deps }

it { is_expected.to contain_class('yum::params') }

it do
is_expected.to contain_yum__config('installonly_limit').with(
ensure: '5',
notify: 'Exec[package-cleanup_oldkernels]'
)
end
end

context 'clean_old_kernels => false' do
let(:params) { { clean_old_kernels: false } }
it { is_expected.to contain_yum__config('installonly_limit').without_notify }
end
end
end
Expand Down