diff --git a/manifests/init.pp b/manifests/init.pp index be81a56a..5b5b09be 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 'restart' parameter to the service resource. @@ -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, @@ -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, diff --git a/manifests/install.pp b/manifests/install.pp index ca690b26..19dbb6b9 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -6,6 +6,7 @@ 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}") @@ -13,8 +14,9 @@ if $package_name != undef { package { $package_name: - ensure => $package_ensure, - alias => 'haproxy', + ensure => $package_ensure, + install_options => $install_options, + alias => 'haproxy', } } } diff --git a/manifests/instance.pp b/manifests/instance.pp index 9e42e015..9d2d5ae7 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -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, 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, @@ -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, diff --git a/spec/classes/haproxy_spec.rb b/spec/classes/haproxy_spec.rb index b43aafc8..3d6174bc 100644 --- a/spec/classes/haproxy_spec.rb +++ b/spec/classes/haproxy_spec.rb @@ -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