Ask Your Question

puppet service with onlyif

asked 2013-11-20 15:22:29 -0600

rakkaus gravatar image

updated 2013-11-21 08:28:32 -0600

golja gravatar image

Can some one help me with puppet, I want to launch my service using something like:

service {"my_service":
  ensure     => running,
  enable     => true,
  hasstatus  => true,
  hasrestart => true,

but It require some folder that can appear at any time and I can't control it. So I want some thing like onlyif =>for service

seems that if my service require some exec with onlyif it's does not work...

edit retag flag offensive close merge delete


I cant use custom fact and I thinking about something like if { check that file exists } else fail('fail')

rakkaus gravatar imagerakkaus ( 2013-11-20 15:30:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-11-25 14:32:30 -0600

Stefan gravatar image

The onlyif parameter is only available for the exec resource. The problem here is that in puppet you define the desired state of the system and puppet will make sure to change the current state to the desired state (if necessary). In your situation your desired state (either "make sure service is running" or "dont care about service") depends on the current state ("is directoy X available?").

The only way to inform the puppet master about the current state (to make the above decision wether the agent should manage the service or not) is to write a custom facts. But ... (more)

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: 2013-11-20 15:22:29 -0600

Seen: 2,963 times

Last updated: Nov 25 '13