Ask Your Question

ensure package installs prior to running module

asked 2016-01-04 13:50:37 -0600

agentguerry gravatar image

updated 2016-01-04 18:15:07 -0600

ramindk gravatar image

So I'm teaching myself puppet and am using this guide below as a start to putting a module in place.

It sets the MOTD to the hostname in ascii text format. It looks like i need to install "figlet" to make it work. I know i can just go to the client and "yum install figlet", but i'd like to figure out how to let puppet handle that part also.

I tried below, but with no success. Running "puppet agent -t" give me an error that it doesn't know what "figlet" is.

class motd {
    $ascii = generate('/bin/sh', '-c', "/usr/bin/figlet -c -w 60 ${hostname}")

    file { 'motd':
        name    => '/etc/motd',
        mode    => '0664',
        owner   => 'root',
        group   => 'root',
        require => Package['figlet'],
        content => template('motd/motd.erb')

How can I make puppet install packages prior to running modules? That way the module and the client know the package/command and run?

Thanks in advance. Its probably easy, but I've yet to find it.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-01-04 18:16:23 -0600

lavaman gravatar image

In a require, you are providing a reference to an existing resource. If the resource is not in the code somewhere, you will get an error that puppet doesn't know what resource you're talking about. You need a package resource that will install figlet before you can reference it in a require.

edit flag offensive delete link more


so is it possible to create a module that just installs packages I want, but make puppet push that module prior to the "motd" one?

agentguerry gravatar imageagentguerry ( 2016-01-04 21:35:12 -0600 )edit

Sure, you can create another class that contains the package resources and require that class in your motd class.

lavaman gravatar imagelavaman ( 2016-01-05 20:54:36 -0600 )edit

answered 2016-01-07 09:50:21 -0600

SimonH gravatar image

Unless you have another module somewhere, you'll probably want to include

package { 'figlet' :
  ensure => present

This does assume that your system can see this as a package (i.e. if it's Linux, you'd need to be able to install via the appropriate package manager.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2016-01-04 13:50:37 -0600

Seen: 125 times

Last updated: Jan 07 '16