Skip to content

Instantly share code, notes, and snippets.

@chrislaskey
Created February 19, 2014 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislaskey/9093545 to your computer and use it in GitHub Desktop.
Save chrislaskey/9093545 to your computer and use it in GitHub Desktop.
Avoiding circular includes when using the profiles / roles pattern in Puppet
# Lesson: always use root scope when including a puppet module inside a profile or role file, e.g.:
# include ::module
# Wrong way
class profile::mail::exim {
include exim
# This expands to current namespace first:
# include profile::mail::exim
# Causing a circular dependency. Include does not throw duplicate errors, so this fails silently.
# Intended 'exim' module is never loaded
}
# Wrong way, with classes
class profile::mail::exim {
class { 'exim': }
# This expands to current namespace first:
# include profile::mail::exim
# Causing a circular dependency. This throws a duplicate error (profile::mail::exim)
# Intended 'exim' module is never loaded
}
# Right way
class profile::mail::exim {
include ::exim
# Looks in root namespace, loads correct module:
# include /etc/puppet/module/exim/manifests/init.pp
}
# Right way, with classes
class profile::mail::exim {
class { '::exim': }
# Looks in root namespace, loads correct module:
# include /etc/puppet/module/exim/manifests/init.pp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment