Circular dependencies

Circular dependencies don't happen often in Puppet development, but when they do, they can be a major pain to troubleshoot. Circular dependencies happen when we create dependency chains with arrow indicators (->) or ordering metaparameters. In the following example, my three notify statements require each other in a circular chain - a -> b -> c -> a:

class profile::baseline::linux {

# notify {'baseline': message => 'Applying the Linux Baseline!' }

notify {'a':
message => 'Resource A',
require => Notify['b']
}

notify {'b':
message => 'Resource B',
require => Notify['c']
}

notify {'c':
message => 'Resource C',
require => Notify['a']
}

}

When this catalog is applied on the node, we'll get a statement letting us know which resources are in a dependency chain:

[root@wordpress puppet]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for wordpress
Info: Applying configuration version '1535603400'
Error: Found 1 dependency cycle:
(Notify[a] => Notify[c] => Notify[b] => Notify[a]) Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
Error: Failed to apply catalog: One or more resource dependency cycles detected in graph

Notice the --graph flag that is indicated in the agent. If we run our agent again, with puppet agent -t --graph, we'll get a dot file back that details our ordering, and we will be able to highlight our dependency cycles. This file is written out to /opt/puppetlabs/puppet/cache/stage/graphs/cycles.dot. I can open this file in GraphViz (open source) or OmniGraffle and view my chain in a graph. The following diagram shows this notification cycle represented in OmniGraffle:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.188.121