You could create a custom fact that returns the desired state of the 
service, based on the existence of the file, and then use the value of that 
fact in the service declaration. For example, like so:

The custom fact:

Facter.add(:state_of_the_service) do
 setcode do
  File.exists?(the-file) ? "running" : "stopped"
 end
end

and the service declaration:

service { 'the-service':
  ensure => $::state_of_the_service
}


The downside of this solution is that you'll require two puppet runs to get 
the service running if the file is (indirectly) created by puppet. The 
first run the file will be created, but the fact is computed at the start 
of the run, so it will still be 'stopped', and only switch to 'running' at 
the start of the second run.

  

On Wednesday, July 8, 2015 at 3:21:48 AM UTC+2, Mark Kirkwood wrote:
>
> I would like to prevent a service starting until a certain file exists. 
> The wrinkle is that the file is not (directly) created by puppet. 
>
> I'm thinking that I want to somehow 'declare' the file to puppet without 
> *it* trying to create it, and the use something like: 
>
> File["the-file"] -> Service["the-service"] 
>
> to make sure the service get started after the file is created. However 
> I'm stumped at the first bit (the file 'declare' idea). Any thoughts? 
>
> Regards 
>
> Mark 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d25abbef-9d0b-4dff-90b7-542419bc12c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to