Ask Your Question

Puppet custom service won't work inside a class block

asked 2014-08-21 15:42:06 -0500

tac-tics gravatar image

I want to use Puppet to host an IRC bot for my company's internet IRC server. The bot has manual start and stop commands. However, I'm running into trouble hooking it into Puppet.

I have a stripped down version of my configuration files:

In ~/puppet/modules/bot/manifests/init.pp....

class bot {
    service { 'bot':
        provider => base,
        ensure => running,
        start => 'touch /tmp/bot',
        stop => 'rm /tmp/bot',
        status => 'test -e /tmp/bot',
        hasstatus => true,

And in "manifests/nodes.pp"....

node 'botserver' {
    include ssh
    include sudoers
    include bot

When I call puppet apply, puppet seems to completely ignore the service block. It will check the bot module's init.pp for syntax errors, but it won't actually create the file in the /tmp directory.

If I pull the service block out and place it directly into the node, it works as expected.

Why am I seeing a discrepancy here?

edit retag flag offensive close merge delete


Apparently, the issue is a naming conflict. Still, props to anyone who can help me figure out exactly why the conflict occurs.

tac-tics gravatar imagetac-tics ( 2014-08-21 16:24:35 -0500 )edit

If you know it is a naming conflict, let's tell Puppet to use bot at the top-most scope. Try: include ::bot

WhatsARanjit gravatar imageWhatsARanjit ( 2014-08-26 12:45:02 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-22 07:37:41 -0500

llowder gravatar image

Make sure that your $moduelpath includes ~/puppet/modules.

By default the modulepath uses $confidr/modules - so /etc/puppet/modules for open source Puppet, /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules for Puppet Enterprise and in both cases ~/.puppet/modules for non-root users.

When I copied your code to /etc/puppetlabs/puppet/modules/bot/manifests/init.pp, then added include bot to my site.pp it created the file /tmp/bot when I ran puppet agent -t.

I noticed in your question that you mentioned puppet apply - puppet apply and puppet agent will use different sections of the config file. If your modulepath = section is in [master] and not [main] then puppet apply won't see or use that setting and will stick with a default value. Alternately, if you use a mix of master/agent and masterless, you can set an apply only modulepath by placing it in the [user] section.

If you are on 3.5+ and are using directory environments, that has a different setup that I am not as familiar with at this time, so cannot comment on beyond that the relevant settings are basemodulepath and environmentpath.

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: 2014-08-21 15:42:06 -0500

Seen: 585 times

Last updated: Aug 22 '14