Skip to content

Commit ee139f8

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

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

manifests/init.pp

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
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+
#
6164
# @param restart_command
6265
# Command to use when restarting the on config changes.
6366
# Passed directly as the <code>'restart'</code> parameter to the service resource.
@@ -131,6 +134,7 @@
131134
Hash $global_options = $haproxy::params::global_options,
132135
Hash $defaults_options = $haproxy::params::defaults_options,
133136
Boolean $merge_options = $haproxy::params::merge_options,
137+
Optional[Array[String]] $install_options = undef,
134138
Optional[String] $restart_command = undef,
135139
Optional[String] $custom_fragment = undef,
136140
Stdlib::Absolutepath $config_dir = $haproxy::params::config_dir,
@@ -173,6 +177,7 @@
173177
haproxy::instance { $title:
174178
package_ensure => $_package_ensure,
175179
package_name => $package_name,
180+
install_options => $install_options,
176181
service_ensure => $_service_ensure,
177182
service_manage => $_service_manage,
178183
service_name => $service_name,

manifests/install.pp

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
# @summary
2-
# Install haproxy
1+
# @summary Install haproxy
2+
# @param install_options
3+
# Array of arguments passed to the installer
34
# @api private
45
define haproxy::install (
56
# lint:ignore:140chars
67
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure,
78
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.
89
# lint:endignore
10+
Array[String[1]] $install_options = [],
911
) {
1012
if $caller_module_name != $module_name {
1113
fail("Use of private class ${name} by ${caller_module_name}")
1214
}
1315

1416
if $package_name != undef {
1517
package { $package_name:
16-
ensure => $package_ensure,
17-
alias => 'haproxy',
18+
ensure => $package_ensure,
19+
install_options => $install_options,
20+
alias => 'haproxy',
1821
}
1922
}
2023
}

manifests/instance.pp

+7-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
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+
#
2225
# @param service_ensure
2326
# Chooses whether the haproxy service should be running & enabled at boot, or
2427
# stopped and disabled at boot. Defaults to 'running'
@@ -161,6 +164,7 @@
161164
define haproxy::instance (
162165
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure = 'present',
163166
Optional[String] $package_name = undef,
167+
Array[String[1]] $install_options = [],
164168
Variant[Enum['running', 'stopped'], Boolean] $service_ensure = 'running',
165169
Boolean $service_manage = true,
166170
Boolean $chroot_dir_manage = true,
@@ -223,8 +227,9 @@
223227
config_validate_cmd => $config_validate_cmd,
224228
}
225229
haproxy::install { $title:
226-
package_name => $package_name,
227-
package_ensure => $package_ensure,
230+
package_name => $package_name,
231+
package_ensure => $package_ensure,
232+
install_options => $install_options,
228233
}
229234
haproxy::service { $title:
230235
instance_name => $instance_service_name,

spec/classes/haproxy_spec.rb

+19
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)