Skip to content

Commit 66f50e9

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

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
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+
# Pass custom options to package installer as an Array of Strings
63+
# Default: undef
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
Variant[Enum['present', 'absent', 'purged', 'disabled', 'installed', 'latest'], String[1]] $package_ensure,
77
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.
88
# lint:endignore
9+
Optional[Array[String]] $install_options = undef,
910
) {
1011
if $caller_module_name != $module_name {
1112
fail("Use of private class ${name} by ${caller_module_name}")
1213
}
1314

1415
if $package_name != undef {
1516
package { $package_name:
16-
ensure => $package_ensure,
17-
alias => 'haproxy',
17+
ensure => $package_ensure,
18+
install_options => $install_options,
19+
alias => 'haproxy',
1820
}
1921
}
2022
}

manifests/instance.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
Optional[String] $custom_fragment = undef,
172172
Optional[Stdlib::Absolutepath] $config_dir = undef,
173173
Optional[Stdlib::Absolutepath] $config_file = undef,
174+
Optional[Array[String]] $install_options = undef,
174175
Variant[Stdlib::Absolutepath, String] $config_validate_cmd = $haproxy::params::config_validate_cmd,
175176
Boolean $merge_options = $haproxy::params::merge_options,
176177
String $service_options = $haproxy::params::service_options,
@@ -223,8 +224,9 @@
223224
config_validate_cmd => $config_validate_cmd,
224225
}
225226
haproxy::install { $title:
226-
package_name => $package_name,
227-
package_ensure => $package_ensure,
227+
package_name => $package_name,
228+
package_ensure => $package_ensure,
229+
install_options => $install_options,
228230
}
229231
haproxy::service { $title:
230232
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)