Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Created August 10, 2018 18:11
Show Gist options
  • Save natemccurdy/ca2ae3f71e29bfe1a66ca1fadce6c5ee to your computer and use it in GitHub Desktop.
Save natemccurdy/ca2ae3f71e29bfe1a66ca1fadce6c5ee to your computer and use it in GitHub Desktop.
An example of the containment problem with roles and profiles in Puppet
# A WebServer role that may have a containment problem.
class role::webserver {
include profile::base
include profile::nginx
# We want EVERYTHING in base to come before the nginx profile
# but that is only possible if the base profile "contains" all of its
# included classes.
Class['profile::base']
-> Class['profile::nginx']
}
class profile::base {
## Here be containment issues!
#include profile::firewall
#include profile::os_settings
#include profile::ldap
#include profile::yum
#include profile::users
## To allow other classes to make relationships to base,
## we should instead contain those included classes.
contain profile::firewall
contain profile::os_settings
contain profile::ldap
contain profile::yum
contain profile::users
}
class profile::nginx {
class { 'nginx':
foo => 'bar',
baz => 'buz',
}
firewalld::service { 'http':
ensure => present,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment