On 09/07/15 01:25, jcbollinger wrote:
>
>
> On Tuesday, July 7, 2015 at 8:21:48 PM UTC-5, 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?
>
>
>
> Puppet doesn't work that way. You cannot use a reference to an
> unmanaged resource (i.e. File["the-file"]). It does not anyway make
> sense to establish a relationship to such a resource; at best it would
> be meaningless. A resource relationship describes an
> order-of-application dependency. What's Puppet supposed to do with that
> if one of the resources involved is not scheduled to be applied at all?
>
> There may be hope, however. You emphasize that the file is not
> /directly/ created by Puppet, but that implies that it is indirectly
> created by Puppet, as a side effect of managing some other resource. If
> you can rely on that other resource to fail in the event that it does
> not create or appropriately modify the file in question, then make that
> the other end of the relationship, maybe
>
> |
> package{'the-service-package':}
> ->
> service {'the-service':}
> |
>
> Otherwise, interpose an Exec between the two that tests for the
> existence (or any other property) of the file:
>
> |
> package{'the-service-package':ensure=>'latest'}
> ->
> exec{'ensure the-file is present':command =>'test -e the-file'}
> ->
> service {'the-service':ensure=>'running'}
> |
>
>
Thanks John,
That worked perfectly! However - and, sorry - I failed to mention that
one of the reasons for doing this was to get rid to errors from puppet
runs, so that scripted builds for testing etc behave well. This solution
seems to still elicit errors when the exec fails to find the file... so
progress but not quite there!
Cheers
Mark