On Monday, February 10, 2014 6:26:56 AM UTC-6, Mikael Lindqvist wrote:
>
> Hi,
>
> Thanks for a great program!
>
> I have one request though, and also wonder if there is some other way to 
> do this...
>
> when I have an exec task, such as:
>
> exec { "task":
>     command => "/bin/some/command",
>     creates => "/some/file/somewhere"
> }
>
> It would be really nice if puppet could check for the existence of the 
> file, and report an error if it does not exist after command has executed. 
> Now the "creates" argument is only used to check if the file exists before 
> the command is run, in order to skip the command if it exists. Possible 
> syntax would be: 
>
> exec { "task":
>     command => "/bin/some/command",
>     mustcreate => "/some/file/somewhere"
> }
>
> Or is there some other method to achieve the same?
>
>

Sure.  You can do this:

$mustcreate = '/some/file/somewhere' 

exec { 'mytask':
  command => '/bin/some/command',
  creates => ${mustcreate}
}

# In the event the Exec['mytask'] needs to be synced,
# sometime after that sync ensure that the $mustcreate
# file exists:
exec { 'mytask-check':
  command => "test -e ${mustcreate}",
  subscribe => Exec['mytask'],
  refreshonly => true
}

If you want to do that a lot then you can minimize repetition of 
boilerplate by creating a defined type around that.


John

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/2ef2f9be-7237-46cf-b9cf-c8dc0e285d46%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to