Skip to content

Commit

Permalink
Add a parameter to package mark hold
Browse files Browse the repository at this point in the history
  • Loading branch information
stjmt committed Jul 30, 2024
1 parent 543c582 commit 6b9a5b0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
# For http, https, and ftp downloads, you may set how long the exec resource
# may take.
#
# @param package_hold
# Set to hold to tell Debian apt/Solaris pkg to hold the package version.
#
# @param package_name
# Name Of the package to install.
#
Expand Down Expand Up @@ -430,12 +433,13 @@
String $default_logging_level = $logging_level,
Optional[String] $keystore_password = undef,
Optional[Stdlib::Absolutepath] $keystore_path = undef,
Stdlib::Filemode $logdir_mode = '2750',
Boolean $package_hold = false,
Optional[Stdlib::Absolutepath] $private_key = undef,
Enum['rsa','dsa','ec'] $private_key_type = 'rsa',
Boolean $restart_config_change = $restart_on_change,
Boolean $restart_package_change = $restart_on_change,
Boolean $restart_plugin_change = $restart_on_change,
Stdlib::Filemode $logdir_mode = '2750',
) {
#### Validate parameters

Expand Down
16 changes: 13 additions & 3 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,19 @@
}

if ($elasticsearch::package_provider == 'package') {
package { 'elasticsearch':
ensure => $package_ensure,
name => $elasticsearch::_package_name,
# You cannot use "mark" property while "ensure" is one of ["absent", "purged", "held"]
if $package_ensure in ['absent', 'purged', 'held'] {
package { 'elasticsearch':
ensure => $package_ensure,
name => $elasticsearch::_package_name,
}
} else {
# https://puppet.com/docs/puppet/7/types/package.html#package-attribute-mark
package { 'elasticsearch':
ensure => $package_ensure,
name => $elasticsearch::_package_name,
mark => ($elasticsearch::package_hold ? { true => 'hold', false => 'none', }),
}
}

exec { 'remove_plugin_dir':
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/000_elasticsearch_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,19 @@
end
end

describe 'with hold enabled' do
let(:params) do
default_params.merge(
package_hold: true
)
end

it {
expect(subject).to contain_package('elasticsearch').
with(mark: 'hold')
}
end

describe 'running a different user' do
let(:params) do
default_params.merge(
Expand Down

0 comments on commit 6b9a5b0

Please sign in to comment.