Skip to content

Commit 27314cf

Browse files
committed
Pass install_options to package installer
1 parent 1b1c22f commit 27314cf

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

manifests/init.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
# or add options without having to recreate the entire hash. Defaults to
5959
# false, but will default to true in future releases.
6060
#
61+
# @param install_options
62+
# Array of arguments passed to the installer
63+
# Default: []
64+
#
6165
# @param restart_command
6266
# Command to use when restarting the on config changes.
6367
# Passed directly as the <code>'restart'</code> parameter to the service resource.
@@ -131,6 +135,7 @@
131135
Hash $global_options = $haproxy::params::global_options,
132136
Hash $defaults_options = $haproxy::params::defaults_options,
133137
Boolean $merge_options = $haproxy::params::merge_options,
138+
Optional[Array[String]] $install_options = undef,
134139
Optional[String] $restart_command = undef,
135140
Optional[String] $custom_fragment = undef,
136141
Stdlib::Absolutepath $config_dir = $haproxy::params::config_dir,
@@ -173,6 +178,7 @@
173178
haproxy::instance { $title:
174179
package_ensure => $_package_ensure,
175180
package_name => $package_name,
181+
install_options => $install_options,
176182
service_ensure => $_service_ensure,
177183
service_manage => $_service_manage,
178184
service_name => $service_name,

manifests/install.pp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# @summary
2-
# Install haproxy
1+
# @summary Install haproxy
2+
# @param install_options
3+
# Array of arguments passed to the installer
4+
# Default: []
35
# @api private
46
define haproxy::install (
57
# lint:ignore:140chars
68
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure,
79
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.
810
# lint:endignore
11+
Array[String[1]] $install_options = [],
912
) {
1013
if $caller_module_name != $module_name {
1114
fail("Use of private class ${name} by ${caller_module_name}")
1215
}
1316

1417
if $package_name != undef {
1518
package { $package_name:
16-
ensure => $package_ensure,
17-
alias => 'haproxy',
19+
ensure => $package_ensure,
20+
install_options => $install_options,
21+
alias => 'haproxy',
1822
}
1923
}
2024
}

manifests/instance.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
# The package name of haproxy. Defaults to undef, and no package is installed.
2020
# NOTE: Class['haproxy'] has a different default.
2121
#
22+
# @param install_options
23+
# Array of arguments passed to the installer
24+
# Default: []
25+
#
2226
# @param service_ensure
2327
# Chooses whether the haproxy service should be running & enabled at boot, or
2428
# stopped and disabled at boot. Defaults to 'running'
@@ -161,6 +165,7 @@
161165
define haproxy::instance (
162166
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure = 'present',
163167
Optional[String] $package_name = undef,
168+
Array[String[1]] $install_options = [],
164169
Variant[Enum['running', 'stopped'], Boolean] $service_ensure = 'running',
165170
Boolean $service_manage = true,
166171
Boolean $chroot_dir_manage = true,
@@ -223,8 +228,9 @@
223228
config_validate_cmd => $config_validate_cmd,
224229
}
225230
haproxy::install { $title:
226-
package_name => $package_name,
227-
package_ensure => $package_ensure,
231+
package_name => $package_name,
232+
package_ensure => $package_ensure,
233+
install_options => $install_options,
228234
}
229235
haproxy::service { $title:
230236
instance_name => $instance_service_name,

spec/classes/haproxy_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,25 @@
657657
end
658658
end
659659

660+
context 'when install_options are specified' do
661+
let(:facts) do
662+
{ os: { family: 'Debian' } }.merge default_facts
663+
end
664+
665+
let(:params) do
666+
{
667+
'install_options' => ['--no-install-recommends'],
668+
}
669+
end
670+
671+
it 'installs the haproxy package' do
672+
subject.should contain_package('haproxy').with(
673+
'ensure' => 'present',
674+
'install_options' => ['--no-install-recommends'],
675+
)
676+
end
677+
end
678+
660679
context 'when on unsupported operatingsystems' do
661680
let(:facts) do
662681
{ os: { family: 'windows' } }.merge default_facts

0 commit comments

Comments
 (0)