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 a parameter to package mark hold #1177

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,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 @@ -403,11 +406,12 @@
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,
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 @@ -381,6 +381,19 @@
with(ensure: 'latest')
}
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
end

describe 'running a a different user' do
Expand Down