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

Support ensuring all yum group packages are installed #140

Merged
merged 1 commit into from
Jan 30, 2020
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
10 changes: 9 additions & 1 deletion manifests/group.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
define yum::group (
Array[String[1]] $install_options = [],
Enum['present', 'installed', 'absent', 'purged'] $ensure = 'present',
Enum['present', 'installed', 'latest', 'absent', 'purged'] $ensure = 'present',
Optional[Integer] $timeout = undef,
) {

Expand All @@ -36,6 +36,14 @@
unless => "yum grouplist hidden '${name}' | egrep -i '^Installed.+Groups:$'",
timeout => $timeout,
}
if $ensure == 'latest' {
ghoneycutt marked this conversation as resolved.
Show resolved Hide resolved
exec { "yum-groupinstall-${name}-latest":
command => join(concat(["yum -y groupinstall '${name}'"], $install_options), ' '),
onlyif => "yum groupinfo '${name}' | egrep '\\s+\\+'",
Copy link

@othalla othalla Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain what you're expecting to filter with egrep

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is looking for +package in the list from groupinfo. If there is no package with + (plus sign) then all packages in the package group are installed and it's not necessary to run yum groupinstall. If a package in the package list has + then it is in the group but not installed on the system so yum groupinstall will ensure all packages get installed.

The existing Exec covers the initial install but the output from yum grouplist hidden $group does not change if some packages are added to a group after it's installed. This PR covers that case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment what the regex is meant to do above the regex.

timeout => $timeout,
require => Exec["yum-groupinstall-${name}"],
}
}
}

'absent', 'purged': {
Expand Down
9 changes: 9 additions & 0 deletions spec/defines/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@
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

context 'when ensure is set to `latest`' do
let(:title) { 'Core' }
let(:params) { { ensure: 'latest' } }

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