"Roles and Profiles" is now the ubiquitous design pattern to create your puppet code tree. In this talk we will discuss writing reusable and maintainable profiles. We ll start by introducing creating module structures and will move on to type hinting and setting appropriate defaults. Finally we ll discuss the importance and the enforcing of code style conventions that allows multiple teams or projects to inner-source profiless
2. $whoami
• Used to be a Molecular Biologist
• Then became a Dev
• Now an Ops
• Currently Cloud Engineer @ The Factory
3. Webserver.pp circapuppet 0.24
includeapache
apache::vhost{ 'vhost.example.com':
port => '80',
docroot => '/var/www/vhost',
}
include::php
class { '::mysql::server':
root_password=> 'secret',
}
class { '::mysql::server::account_security':}
class { '::mysql::client': }
mysql::db{ 'mydb':
user => 'myuser',
password=> 'topsecret',
host => 'localhost',
grant => ['SELECT', 'UPDATE'],
}
include::firewall
firewall{'http':
dport => '80',
proto => 'tcp',
action => 'accept',
}
4. Webserver.pp circapuppet 0.24
class customer_x inherits webserver {
includecustomer_x
}
class customer_y inherits webserver {
includecustomer_y
}
5. A design pattern emerged
• Component modules — Modules that manage one particular technology.
• Profiles — Wrapper classes that use (multiple) component modules to configure a layered technology stack.
• Roles — Wrapper classes that use multiple profiles to build a complete system configuration.
https://www.craigdunn.org/2012/05/239/
6. Roles & Profiles
class roles::webserver {
include::profiles::apache
}
class roles::database {
include::profiles::mysql
}
class roles::allinone {
include::profiles::apache
include::profiles::mysql
}
20. Feature flag it all
class profiles::website (
Boolean $apache = false,
Boolean $nginx = false,
Boolean $traefik = false,
){
if $apache{
class {'::profiles::website::apache': }
}
if $nginx{
class {'::profiles::website::nginx': }
}
if $traefik{
class {'::profiles::website::traefik': }
}
}