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

Add optional parameters to groupinstall #86

Merged
merged 5 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,17 @@ yum::versionlock { '0:bash-4.1.2-9.el6_2.*':

### Install or remove *yum* package group

Install yum [package groups](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sec-working_with_package_groups). To list groups: `yum group list`. Then use that name in your puppet manifest. With support for install_options (e.g. enable repos if disabled by default).

```puppet
yum::group { 'X Window System':
ensure => present,
timeout => 600,
ensure => present,
timeout => 600,
install_options => ['--enablerepo=*'];
}
```


### Install or remove packages via `yum install`

This is a workaround for [PUP-3323](https://tickets.puppetlabs.com/browse/PUP-3323). It enables the installation of packages from non-repo sources while still providing dependency resolution. For example, say there is a package *foo* that requires the package *bar*. *bar* is in a Yum repository and *foo* is stored on a stand-alone HTTP server. Using the standard providers for the `Package` resource type, `rpm` and `yum`, the `rpm` provider would be required to install *foo*, because only it can install from a non-repo source, i.e., a URL. However, since the `rpm` provider cannot do dependency resolution, it would fail on its own unless *bar* was already installed. This workaround enables *foo* to be installed without having to define its dependencies in Puppet.
Expand Down
9 changes: 6 additions & 3 deletions manifests/group.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# [*ensure*] - specifies if package group should be
# present (installed) or absent (purged)
# [*timeout*] - exec timeout for yum groupinstall command
# [*install_options*] - options provided to yum groupinstall command
#
# Actions:
#
Expand All @@ -18,9 +19,11 @@
# }
#
define yum::group (
Enum['present', 'installed', 'absent', 'purged'] $ensure = 'present',
Optional[Integer] $timeout = undef,
Array[String[1]] $install_options = [],
Enum['present', 'installed', 'absent', 'purged'] $ensure = 'present',
Optional[Integer] $timeout = undef,
) {

Exec {
path => '/bin:/usr/bin:/sbin:/usr/sbin',
environment => 'LC_ALL=C',
Expand All @@ -29,7 +32,7 @@
case $ensure {
'present', 'installed', default: {
exec { "yum-groupinstall-${name}":
command => "yum -y groupinstall '${name}'",
command => join(concat(["yum -y groupinstall '${name}'"], $install_options), ' '),
unless => "yum grouplist hidden '${name}' | egrep -i '^Installed.+Groups:$'",
timeout => $timeout,
}
Expand Down
7 changes: 7 additions & 0 deletions spec/defines/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_exec("yum-groupinstall-#{title}").with_timeout(30) }
end
context 'with an install option specified' do
let(:title) { 'Core' }
let(:params) { { install_options: ['--enablerepo=epel'] } }

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_exec("yum-groupinstall-#{title}").with_command("yum -y groupinstall 'Core' --enablerepo=epel") }
end
end