Skip to content

Commit

Permalink
Add parameter clean_old_kernels that can be used to disable cleaning …
Browse files Browse the repository at this point in the history
…up of old kernels when installonly_limit is changed
  • Loading branch information
treydock committed Nov 7, 2016
1 parent 7456b5a commit 00d336a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
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

0 comments on commit 00d336a

Please sign in to comment.