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 27314cf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 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
# Array of arguments passed to the installer
# Default: []
#
# @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
12 changes: 8 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# @summary
# Install haproxy
# @summary Install haproxy
# @param install_options
# Array of arguments passed to the installer
# Default: []
# @api private
define haproxy::install (
# lint:ignore:140chars
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
Array[String[1]] $install_options = [],
) {
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',
}
}
}
10 changes: 8 additions & 2 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
# The package name of haproxy. Defaults to undef, and no package is installed.
# NOTE: Class['haproxy'] has a different default.
#
# @param install_options
# Array of arguments passed to the installer
# Default: []
#
# @param service_ensure
# Chooses whether the haproxy service should be running & enabled at boot, or
# stopped and disabled at boot. Defaults to 'running'
Expand Down Expand Up @@ -161,6 +165,7 @@
define haproxy::instance (
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure = 'present',
Optional[String] $package_name = undef,
Array[String[1]] $install_options = [],
Variant[Enum['running', 'stopped'], Boolean] $service_ensure = 'running',
Boolean $service_manage = true,
Boolean $chroot_dir_manage = true,
Expand Down Expand Up @@ -223,8 +228,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 27314cf

Please sign in to comment.