Ordering puppet resources with run stages
class runstages::standard {
# declare additional run stage
stage { 'stage01': }
Stage['stage01'] -> Stage['main']
# assign classes to stages
class { 'yumrepos':
stage => 'stage01',
}->
class {'authentication': # Active Directory auth setup
stage => 'stage01',
}->
class {'hosts': # hosts file
stage => 'stage01',
}
}
Stage['main'] is the default run stage. If we don't explicitly assign a puppet class to a stage, then it will be in the main stage.
In the above example, created a custom stage called stage01 and assigned classes to it. As we can see, stage01 is fired before the stage main. The -> chaining arrows also ensure ordering. So, the three classes within the stage01 are run in a specific order. As an alternative, we could have specified three different run stages for each class, but we prefer grouping all three into a run stage, for scalability.
Then apply the runstages::standard class to our hosts via our External Node Classifier (ENC) e.g. Foreman, if we use one, or in our site manifest. With Foreman, I had to remove the puppet classes yum repo, authentication, and hosts from my host group(s) otherwise you'll get duplicate declaration warnings.
Relevant Blogs:
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post