ReleaseEngineering/PuppetAgain/HowTo/Hack on PuppetAgain: Difference between revisions

Jump to navigation Jump to search
Line 53: Line 53:


== Strong Dependencies ==
== Strong Dependencies ==
Wherever a dependency might exist, specify it.  Dependency errors are difficult to spot when you're incrementally building a system as you develop your patch.  Unspecified dependencies can even work in production -- for a while, until a new and unrelated resource shakes up the ordering and suddenly things don't work.
Wherever a dependency might exist, specify it.  Dependency errors are difficult to spot when you're incrementally building a system as you develop your patch.  Unspecified dependencies can even work in production -- for a while, until a new and unrelated resource shakes up the nondeterministic ordering and suddenly things don't work.


You can get puppet to give you a dependency graph in .dot format!  See http://bitfieldconsulting.com/puppet-dependency-graphs - although the results are enormous:
=== Graphs ===
You can get puppet to give you a dependency graph in .dot format!  See http://bitfieldconsulting.com/puppet-dependency-graphs - although the results are enormous and due to some puppet bugs not that helpful.
   yum install graphviz
   yum install graphviz
   dot -Tpng /var/lib/puppet/state/graphs/expanded_relationships.dot > relationships.png
   dot -Tpng /var/lib/puppet/state/graphs/expanded_relationships.dot > relationships.png


In general, use ''require => Class['some::class']'' rather than requiring a basic resource that you know the class defines (especially avoid ''require => Package['some-package']'').  This way, you are not depending on an implementation detail of that other class.  This also creates many more dependencies (on all of the resources in that class), which keeps things predictable.
=== Class Dependencies ===
In general, use ''require => Class['some::class']'' rather than requiring a basic resource that you know the class defines (especially avoid ''require => Package['some-package']'').  This way, you are not depending on an implementation detail of that other class.  This also creates many more dependencies (on all of the concrete resources in that class), which keeps things predictable.


Keep in mind that puppet automatically requires parent directories, so ''File['/builds/slave']'' automatically requires ''File['/builds']'' if it exists.  Also, note that in many cases packages will write default configuration files when they are installed, so you should make sure that the File resource installing the configuration requires the package class.
Unfortunately, these dependencies do *not* extend to included classes.  See [[ReleaseEngineering/PuppetAgain/Anchoring Classes]] for the workaround.  Every class that might be required by another class (which is, more or less, any class documented on the wiki) should be anchored.
 
=== Tips ===
Keep in mind that puppet automatically requires parent directories, so ''File['/builds/slave']'' automatically requires ''File['/builds']'' if it exists.  Also, note that in many cases packages will write default configuration files when they are installed, so you should make sure that the File resource installing the custom configuration requires the package class.


== Document ==
== Document ==
canmove, Confirmed users
1,394

edits

Navigation menu