Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make a puppet class dependent on all of the resources it defines?
    text
    copied!<p>I am working on a rather large and complicated puppet module, and I ran into an issue where declaring a dependency on a class does not translate to a dependency on class resources defined in that class. I have created an example.</p> <pre><code>node default { notify {'This is my notification': require =&gt; Class['big_class'], } class {'big_class':} } class big_class { notify {'This is my big class':} class {'little_class':} } class little_class{ notify {'This is my little class':} class {'smallest_class':} } class smallest_class { notify {'This is my smallest class':} } </code></pre> <p>My desired behavior is for smallest, little, and big to all resolve before the notification. But Puppet doesn't work this way. The result of the run is as follows:</p> <pre><code>Notice: This is my little class Notice: /Stage[main]/Little_class/Notify[This is my little class]/message: defined 'message' as 'This is my little class' Notice: This is my big class Notice: /Stage[main]/Big_class/Notify[This is my big class]/message: defined 'message' as 'This is my big class' Notice: This is my notification Notice: /Stage[main]//Node[default]/Notify[This is my notification]/message: defined 'message' as 'This is my notification' Notice: This is my smallest class Notice: /Stage[main]/Smallest_class/Notify[This is my smallest class]/message: defined 'message' as 'This is my smallest class' Notice: Finished catalog run in 0.05 seconds </code></pre> <p>The smallest class resolved after the 'This is my notification' even though it is defined effectively 'within' a requirement on the notification. What is the best practice for handling this type of senario? If this is the desired behavior, is there a way to declare that resources defined within a class are requirements of that class? Do all of the resources inside of <code>class class_name</code> need to have a meta-parameter <code>before =&gt; Class['class_name'],</code>?</p> <p>Edit: The following results in puppet complaining about dependency cycles.</p> <pre><code>class smallest_class { notify {'This is my smallest class': before =&gt; Class['smallest_class'], } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload