Yum package groups are collections of related packages that can be installed as a single unit. Common examples include "Development Tools" or "Web Server". These are particularly useful when setting up new servers with specific functionalities.
Since Puppet 3.3.0, the package resource type has supported installing package groups directly through the yum
provider. This is more reliable than using exec
resources as it integrates with Puppet's resource management system.
Here's the simplest way to install a package group:
package { 'Development Tools':
ensure => 'installed',
provider => 'yumgroup',
}
For more control over the installation:
package { 'Web Server':
ensure => 'present',
provider => 'yumgroup',
install_options => ['--setopt=group_package_types=mandatory,default'],
timeout => 300,
}
You can verify what packages are included in a group using:
exec { 'list-group-packages':
command => 'yum groupinfo "Development Tools"',
path => ['/usr/bin', '/bin'],
}
For systems using DNF (like newer Fedora versions), the approach is similar:
package { 'Development Tools':
ensure => 'installed',
provider => 'dnfgroup',
}
1. Group name variations: Some groups have different names across distributions. Always verify the exact group name with yum grouplist
.
2. Slow operations: Package group installations can be time-consuming. Set appropriate timeouts in your Puppet manifests.
When managing CentOS/RHEL systems with Puppet, you'll often need to install package groups like 'Development Tools' or 'Web Server'. While exec
with yum groupinstall
works, it's not the most Puppet-idiomatic solution.
Puppet's package
resource type actually supports yum groups natively:
package { 'Development Tools':
ensure => 'installed',
provider => 'yum',
install_options => ['--nogpgcheck', '--skip-broken'],
}
For groups containing spaces, use quotes in the title:
package { '"Web Server"':
ensure => present,
provider => 'yum',
}
You can combine this with Hiera for dynamic group installation:
$yum_groups.each |String $group| {
package { $group:
ensure => installed,
provider => 'yum',
}
}
To verify installation in your manifests:
if $facts['yum_groups'] and 'Development Tools' in $facts['yum_groups'] {
notify { 'devtools_installed':
message => 'Development Tools group is already installed'
}
}
While exec
works, the native package resource provides:
- Better idempotency handling
- Integration with Puppet's dependency system
- Cleaner reporting in Puppet runs
Common issues and solutions:
# Debugging group installation
exec { 'debug-yum-groups':
command => 'yum groups list',
path => '/usr/bin:/bin',
logoutput => true,
}