Created
February 19, 2014 14:47
-
-
Save chrislaskey/9093545 to your computer and use it in GitHub Desktop.
Avoiding circular includes when using the profiles / roles pattern in Puppet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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