Does puppet have a way to install a yum package group (e.g. 'Development Tools'), besides exec?

link|improve this question

58% accept rate
feedback

3 Answers

I couldn't find anything in the Puppet Type Reference for the Package type, so I asked on the Puppet IRC channel on Freenode (#puppet, oddly) and got nothing so I think the answer is "not yet".

link|improve this answer
feedback

You could handle this through an Puppet Exec Type to execute the necessary group install. I would be sure to include a good onlyif or unless option so that it only executes it when needed or set to refreshonly and trigger it via a Notify so that it is not run every time though. The Exec type will execute the command locally on the puppet client for you provided it is triggered.

link|improve this answer
feedback

Here's a definition of a 'yumgroup' puppet resource type. It installs default and mandatory packages by default, and can install optional packages.

This definition can't remove yum groups yet though it though it would be easy to make it happen. I didn't bother for myself because it can cause loops in puppet under certain circumstances.

This type requires the yum-downloadonly rpm to be installed and I think it only works on RHEL/CentOS/SL 6. At the time I wrote this, yum's exit statuses on previous versions were wrong so the 'unless' parameter wouldn't work without being extended to grep for output.

define yumgroup($ensure = "present", $optional = false) {
   case $ensure {
      present,installed: {
         $pkg_types_arg = $optional ? {
            true => "--setopt=group_package_types=optional,default,mandatory",
            default => ""
         }
         exec { "Installing $name yum group":
            command => "yum -y groupinstall $pkg_types_arg $name",
            unless => "yum -y groupinstall $pkg_types_arg $name --downloadonly",
            timeout => 600,
         }
      }
   }
}

I've deliberately omitted making yum-downloadonly a dependency as it might conflict with others' manifests. If you want to do this, declare the yum-downloadonly package in a separate manifest and include that within this define. Don't declare directly in this define otherwise puppet will give an error if you use this resource type more than once. The exec resource should then require Package['yum-downloadonly'].

link|improve this answer
Thanks for this! I created a module called yum_groupinstalls and created an init.pp manifest with your definition and a class to install the Development tools group. Note that I had to quote the group name: class yum_groupinstalls { yumgroup { '"Development tools"': } } In the definition I had to specify the full path to yum which was /usr/bin/yum for me on CentOS 6.2. – Banjer May 21 at 18:41
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.