diff --git a/manifests/init.pp b/manifests/init.pp index be81a56a..08e95b1a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -58,6 +58,9 @@ # 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 +# # @param restart_command # Command to use when restarting the on config changes. # Passed directly as the 'restart' parameter to the service resource. @@ -131,6 +134,7 @@ Hash $global_options = $haproxy::params::global_options, Hash $defaults_options = $haproxy::params::defaults_options, Boolean $merge_options = $haproxy::params::merge_options, + Array[String[1]] $install_options = [], Optional[String] $restart_command = undef, Optional[String] $custom_fragment = undef, Stdlib::Absolutepath $config_dir = $haproxy::params::config_dir, @@ -173,6 +177,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..8d7dd479 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,11 +1,13 @@ -# @summary -# Install haproxy +# @summary Install haproxy +# @param install_options +# Array of arguments passed to the installer # @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}") @@ -13,8 +15,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..75da893d 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -19,6 +19,9 @@ # 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 +# # @param service_ensure # Chooses whether the haproxy service should be running & enabled at boot, or # stopped and disabled at boot. Defaults to 'running' @@ -161,6 +164,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, @@ -223,8 +227,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