Skip to content

Commit

Permalink
Pass install_options to package installer
Browse files Browse the repository at this point in the history
  • Loading branch information
deric committed Feb 23, 2024
1 parent 1b1c22f commit 66f50e9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
# or add options without having to recreate the entire hash. Defaults to
# false, but will default to true in future releases.
#
# @param install_options
# Pass custom options to package installer as an Array of Strings
# Default: undef
#
# @param restart_command
# Command to use when restarting the on config changes.
# Passed directly as the <code>'restart'</code> parameter to the service resource.
Expand Down Expand Up @@ -131,6 +135,7 @@
Hash $global_options = $haproxy::params::global_options,
Hash $defaults_options = $haproxy::params::defaults_options,
Boolean $merge_options = $haproxy::params::merge_options,
Optional[Array[String]] $install_options = undef,
Optional[String] $restart_command = undef,
Optional[String] $custom_fragment = undef,
Stdlib::Absolutepath $config_dir = $haproxy::params::config_dir,
Expand Down Expand Up @@ -173,6 +178,7 @@
haproxy::instance { $title:
package_ensure => $_package_ensure,
package_name => $package_name,
install_options => $install_options,
service_ensure => $_service_ensure,
service_manage => $_service_manage,
service_name => $service_name,
Expand Down
6 changes: 4 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure,
Optional[String] $package_name = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
# lint:endignore
Optional[Array[String]] $install_options = undef,
) {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

if $package_name != undef {
package { $package_name:
ensure => $package_ensure,
alias => 'haproxy',
ensure => $package_ensure,
install_options => $install_options,
alias => 'haproxy',
}
}
}
6 changes: 4 additions & 2 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
Optional[String] $custom_fragment = undef,
Optional[Stdlib::Absolutepath] $config_dir = undef,
Optional[Stdlib::Absolutepath] $config_file = undef,
Optional[Array[String]] $install_options = undef,

Check warning on line 174 in manifests/instance.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

missing documentation for defined type parameter haproxy::instance::install_options (check: parameter_documentation)

Check warning on line 174 in manifests/instance.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

missing documentation for defined type parameter haproxy::instance::install_options (check: parameter_documentation)

Check warning on line 174 in manifests/instance.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

missing documentation for defined type parameter haproxy::instance::install_options (check: parameter_documentation)

Check warning on line 174 in manifests/instance.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

missing documentation for defined type parameter haproxy::instance::install_options (check: parameter_documentation)
Variant[Stdlib::Absolutepath, String] $config_validate_cmd = $haproxy::params::config_validate_cmd,
Boolean $merge_options = $haproxy::params::merge_options,
String $service_options = $haproxy::params::service_options,
Expand Down Expand Up @@ -223,8 +224,9 @@
config_validate_cmd => $config_validate_cmd,
}
haproxy::install { $title:
package_name => $package_name,
package_ensure => $package_ensure,
package_name => $package_name,
package_ensure => $package_ensure,
install_options => $install_options,
}
haproxy::service { $title:
instance_name => $instance_service_name,
Expand Down
19 changes: 19 additions & 0 deletions spec/classes/haproxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,25 @@
end
end

context 'when install_options are specified' do
let(:facts) do
{ os: { family: 'Debian' } }.merge default_facts
end

let(:params) do
{
'install_options' => ['--no-install-recommends'],
}
end

it 'installs the haproxy package' do
subject.should contain_package('haproxy').with(
'ensure' => 'present',
'install_options' => ['--no-install-recommends'],
)
end
end

context 'when on unsupported operatingsystems' do
let(:facts) do
{ os: { family: 'windows' } }.merge default_facts
Expand Down

0 comments on commit 66f50e9

Please sign in to comment.