Ask Your Question
1

Install multiple packages with wildcard (*)

asked 2015-04-01 18:39:43 -0500

R gravatar image

updated 2015-04-02 12:14:07 -0500

GregLarkin gravatar image

Hello,

I am a novice to puppet. I am trying to leverage puppet to install packages on a Linux host. Does puppet accept wild cards (for example *)? For example if I do a yum install motif*, it installs all the packages starting openmotif. How do we go about achieving that through puppet. I couldn't find the answer to this question on puppet community. My apologies if this question is already asked. Here is the script:

class pkgs_install
{
 if $::osfamily == 'RedHat' 
 {
 $pkgs_list = [
   'binutils',
   'compat-db',
   'gcc',
   'openmotif*'
       ]
  package { $pkgs_list:
     ensure => latest,
        }
  }
}
include pkgs_install
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-04-02 12:38:09 -0500

GregLarkin gravatar image

Yes, this does work:

# rpm -qa | grep motif
# puppet apply -e "package { 'openmotif*': ensure => installed, }"
Notice: Compiled catalog for master.puppetlabs.vm in environment production in 0.45 seconds
Notice: /Stage[main]/Main/Package[openmotif*]/ensure: created
Notice: Finished catalog run in 9.74 seconds
# rpm -qa | grep motif
openmotif-2.3.3-8.el6.i686
openmotif-devel-2.3.3-8.el6.i686
openmotif22-2.2.3-19.el6.i686
#

However, be aware that if you do that, you've now lost some of the information about how your machine is configured. By using wildcards, you've ceded control of what packages are installed to the package repository instead of strictly declaring which ones you want.

I would argue for specifically enumerating the packages you want installed in order to avoid future problems. You can certainly place the package list in a variable as you've done and move that to a separate class (class pkg_install::params if you want to use the parameter defaults pattern) to make the code cleaner.

edit flag offensive delete link more

Comments

Thanks Greg, yes I totally agree with you that using wild cards is not a good option. Anyways thanks a lot for the reply.

R gravatar imageR ( 2015-04-02 18:32:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-04-01 18:39:43 -0500

Seen: 2,615 times

Last updated: Apr 02 '15