Ask Your Question

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


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 = [
  package { $pkgs_list:
     ensure => latest,
include pkgs_install
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

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

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


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


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

Seen: 2,542 times

Last updated: Apr 02 '15