Skip to content

Commit

Permalink
Add package_install_options variable to allow you to pass flags to …
Browse files Browse the repository at this point in the history
…the package resource statements
  • Loading branch information
Karl vollmer authored and wbclark committed Feb 10, 2021
1 parent 676326b commit 7f3bbf0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 6 deletions.
8 changes: 5 additions & 3 deletions manifests/agent/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
$package_name = $puppet::client_package,
$package_version = $puppet::version,
$package_provider = $puppet::package_provider,
$package_install_options = $puppet::package_install_options,
$package_source = $puppet::package_source,
) {
if $manage_packages == true or $manage_packages == 'agent' {
package { $package_name:
ensure => $package_version,
provider => $package_provider,
source => $package_source,
ensure => $package_version,
provider => $package_provider,
install_options => $package_install_options,
source => $package_source,
}
}
}
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@
# Defaults to undef. If 'windows' or 'msi' are
# used as the provider then this setting is
# required.
# $package_install_options:: Flags that should be passed to the package manager
# during installation. Defaults to undef. May be
# a string or a hash, see Puppet Package resource
# documentation for the provider matching your package manager
#
# $unavailable_runmodes:: Runmodes that are not available for the
# current system. This module will not try
Expand Down Expand Up @@ -563,6 +567,7 @@
Optional[String] $dir_owner = $puppet::params::dir_owner,
Optional[String] $dir_group = $puppet::params::dir_group,
Optional[String] $package_provider = $puppet::params::package_provider,
Optional[Variant[String,Hash]] $package_install_options = $puppet::params::package_install_options,
Optional[Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl]] $package_source = $puppet::params::package_source,
Integer[0, 65535] $port = $puppet::params::port,
Boolean $pluginsync = $puppet::params::pluginsync,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
}

$package_source = undef
$package_install_options = undef

# Need your own config templates? Specify here:
$auth_template = 'puppet/auth.conf.erb'
Expand Down
3 changes: 2 additions & 1 deletion manifests/server/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
$server_version = pick($puppet::server::version, $puppet::version)

package { $server_package:
ensure => $server_version,
ensure => $server_version,
install_options => $puppet::package_install_options,
}

if $puppet::server::manage_user {
Expand Down
1 change: 1 addition & 0 deletions spec/classes/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
.with_ensure('present')
.with_provider(package_provider)
.with_source(nil)
.with_install_options(nil)
end

# config
Expand Down
5 changes: 4 additions & 1 deletion spec/classes/puppet_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
it { should_not contain_class('puppet::server') }
it { should contain_file(puppet_directory).with_ensure('directory') }
it { should contain_concat(puppet_concat) }
it { should contain_package(puppet_package).with_ensure('present') }
it { should contain_package(puppet_package)
.with_ensure('present')
.with_install_options(nil)
}
end

describe 'with server => true', :unless => unsupported_puppetmaster_osfamily(facts[:osfamily]) do
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/puppet_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# install
it { should contain_class('puppet::server::install') }
it { should contain_user('puppet') }
it { should contain_package(puppetserver_pkg) }
it { should contain_package(puppetserver_pkg).with_install_options(nil) }

# config
it { should contain_class('puppet::server::config') }
Expand Down

0 comments on commit 7f3bbf0

Please sign in to comment.