Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass install_options to package installer #603

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>'restart'</code> parameter to the service resource.
Expand Down Expand Up @@ -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,
Optional[Array[String]] $install_options = undef,
deric marked this conversation as resolved.
Show resolved Hide resolved
Optional[String] $restart_command = undef,
Optional[String] $custom_fragment = undef,
Stdlib::Absolutepath $config_dir = $haproxy::params::config_dir,
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# @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}")
}

if $package_name != undef {
package { $package_name:
ensure => $package_ensure,
alias => 'haproxy',
ensure => $package_ensure,
install_options => $install_options,
alias => 'haproxy',
}
}
}
9 changes: 7 additions & 2 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions spec/classes/haproxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading