Issue #3537 has been updated by eric sorenson.
Let me rephrase Alan's #note-11 because it is a useful point of discussion but
has an error in the code
<pre>
exec { "A":
command => "A.command",
onlyif => "A.onlyif",
require => Exec["B"],
}
exec { "B":
command => "B.command",
refreshonly => true,
}
</pre>
the current behaviour is:
<pre>
run A.onlyif;
if A.onlyif was sucessful {
run A.command
run B.command
}
</pre>
I believe that Kjetil wants a way to express the following behaviour:
<pre>
run A.onlyif;
if A.onlyif was sucessful {
run B.command;
run A.command;
}
</pre>
But to do that means we'd have to pause evaluating resource A, go to B, then
come back to A. A much simpler way to model this would be not to use the
`onlyif` at all but instead make its command a top-level exec resource too. It
will be run every time either way so there's no performance hit, and the
savings in complexity seems quite worthwhile. So you'd have
<pre>
exec { "prereq":
command => "formerly A.onlyif"
notify => Exec["B"]
}
exec { "A":
command => "A.command",
refreshonly => true,
}
exec { "B":
command => "B.command",
refreshonly => true,
notify => Exec["A"]
}
<pre>
Which, as far as I can tell, gets you to exactly the same state without weird
runarounds.
More on the apt-get situation in a moment.
----------------------------------------
Feature #3537: It should be possible to trigger (exec) resources with require
https://projects.puppetlabs.com/issues/3537#change-91319
* Author: Kjetil Torgrim Homme
* Status: Needs Decision
* Priority: Normal
* Assignee: eric sorenson
* Category: metaparameters
* Target version:
* Affected Puppet version: 0.25.4
* Keywords:
* Branch:
----------------------------------------
When an Exec has conditions associated with it (unless, creates, onlyif), it
can be useful to be state prerequisites which are only run when the exec itself
is run.
Consider this simple example::
<pre>
exec { "prereq":
command => "/bin/echo prereq",
refreshonly => true
}
exec { "main":
command => "/bin/echo main",
onlyif => "/bin/grep foobar /etc/issue",
require => Exec["prereq"]
}
</pre>
Here, the refreshonly will cause "prereq" to never run, since a require isn't
enough to trigger it. Without refreshonly, it will run every time, but the
desired behaviour is that "prereq" is run iff the onlyif command succeeds.
Obviously the behaviour of "refreshonly => true" can't change, and I can't
think of a good name for a tri-state alternative -- "refreshonly =>
'requires-too'" ? "allevents" may be more workable.
My prefered solution would be a new parameter "requireonly". Perhaps slightly
misleading name, since "before" should trigger execution, too, but I think most
people will understand that require/before are inherently intertwined. This
could later be generalised into a metaparameter to work for more types, e.g.
you could have a parent File which is only checked/updated/created when some
other File requires it.
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.