Explicit high-level dependencies in Puppet

October 9, 2019 – Samuli Seppänen

I've noticed that some people - I won't reveal their names here to protect them - love using contain and/or ordering arrows in Puppet. A typical use-case is for role classes:

class role::webserver {
  contain ::packetfilter::endpoint
  contain ::profile::monit
  contain ::profile::unixbase
  contain ::profile::ipa_client
  contain ::profile::webserver

  Class[::packetfilter::endpoint]
  -> Class[::profile::monit]
  -> Class[::profile::unixbase]
  -> Class[::profile::ipa_client]
  -> Class[::profile::webserver]
 }

The above code nicely ensures that all the classes get applied in the exact order defined above. What happens under the hood is that Puppet generates dependencies between the classes and applies them in order.

Serializing the execution order probably has some performance cost as Puppet is not able to run as many tasks at any given time as it otherwise could. I'm not sure if this has any practical effect. Another issue is that if Puppet run fails at any of the above classes none of the classes that come after will not get applied. So, instead of just one tiny thing failing a large chunk of the catalog fails.

I have not been a big fan of creating dependencies between high-level resources such as profiles. In pretty much all cases you need to define dependencies between resources anyways, and if you do that properly, you don't need to declare high-level dependencies at all.

That said, today was the first time I actually ran into a problem with the above pattern in roles (such as the above) when ipa-client package on a particular OS had a bug which caused ::profile::ipa_client to fail. So the belt and suspenders is not that bad, even if it is somewhat reduntant in many cases.

EDIT: fixed wrong terminology. The above did not represent the classic anchor pattern as I originally claimed.

...

Want to talk to an expert?

If you want to reach us, just send us a message or book a free call!
Categories

Tags

#aad #Access #acl #alertmanager #ansible #ansible module development #Apache #API #augeas #authentication #authorization #automation #automatization #aws #azure #backup #bash #bitbucket #buildbot #cache #centos #cloud #cloud-init #cloudflare #cloudfront #cluster #connectionsJpa #control repo #custom fact #database #debian #devops #digital sovereignty #DNS #docker #domain mode #duplo #ejabberd #email #encryption #erb #europe #eyaml #fabric #facter #facts #fargate #fedora #file #finnish #foreman #freeipa #git #github #gitlab #gnome #google #grafana #hammer #hiera #IAM #import #infinispan #Infrastructure as Code #ipmi #irc #jboss #jdk #jenkins #JMESPath #kanban #keycloak #librarian-puppet #librenms #linkedin #Linux #Location #loop #marketing #mautic #Mellon #mfa #monitoring #mysql #nagios #network-manager #oauth #oauth2 #office365 #open source #openvpn #oxygen #packer #paranormal #pdk #people #php #pkcs7 #pomodoro #Powershell #preseed #presentation #profiles #prometheus #provisioning #puppet #puppet-bolt #puppet-litmus #puppetboard #puppetdb #Puppetfile #puppetserver #puppet types and providers #pxeboot #qemu #quality #r10k #recruitment #redirect #Restrict #Reverse Proxy #roles #rspec #ruby #SAML #sem #shell #showsql #snmp #snmpd #software developement #spam #ssh #sso #standardization #systemd #systemd-resolved #teams #terraform #ubuntu #user-data #vagrant #vanity awards #variable #vim #virtualbox #visualstudio #webdevelopment #wildfly #Windows #wireguard #wordpress #workflow #x11 #xmpp #zimbra
We are
 Puppeteers
menucross-circle