Ask Your Question
0

ensure package installs prior to running module

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

agentguerry gravatar image

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

ramindk gravatar image

So I'm teaching myself puppet and am using this guide below as a start to putting a module in place. http://littlebloghome.blogspot.com/20...

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
0

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

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

Comments

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 -0500 )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 -0500 )edit
0

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

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

Stats

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

Seen: 116 times

Last updated: Jan 07 '16