On Jan 28, 8:12 am, Patrick Cervicek
<[email protected]> wrote:
> Is there a way to create a file only under certain conditions?
What Daniel said.
For the record, though:
> class hibernate {
>
> notice("hibernate")
>
> exec { "echo":
> alias => "echo",
> # onlyif => "test -b /dev/mapper/swap_crypt -a ! -f
> /etc/initramfs-tools/conf.d/resume" ,
> # onlyif => "true" ,
> onlyif => "false" ,
> }
>
> # should not be created as Exec["echo"] is "false"!
> # ... but "resume" is still created
> file { "resume":
> name => "/etc/initramfs-tools/conf.d/resume",
> source => "puppet:///modules/hibernate/resume",
> mode => 644,
> require => Exec["echo"],
> }
I think you have a misconception here about the semantics of onlyif.
OnlyIf does not cause an Exec to fail when its condition is false.
Instead, it causes the Exec to *succeed* without actually running the
command. This is intentional, with the express purpose that resources
that depend on an Exec are still applied when the Exec is short-
circuited.
More generally, the Exec resource is not intended for the purpose to
which you are trying to put it. You could probably force it to serve
by making your onlyif command be the main command, but that's ugly,
and it will report errors on most runs. Instead, the puppetmaster
should decide, based on the facts presented to it, what resources
should be applied on each node.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.