1

I am using hiera with puppet and have a puppet role/profile setup, where 1 role includes multiple profiles (as shown below). My build role includes hardcoded profiles with a number of chains at the bottom.

# build.pp - Current Role
class role::build {

  include profile::profile1
  include profile::profile2
  include profile::profile3

  Class['profile::profile1']
  ->Class['profile::profile2']
  ->Class['profile::profile3']
}

I am looking to convert this role (build.pp) to use puppet hiera lookup to find class names and have them added to the puppet catalog. My proposed role would look something like this:

# build.pp - Proposed Role
class role::build {

  lookup('classes', Array[String], 'unique').include

  Class['profile::profile1']
  ->Class['profile::profile2']
  ->Class['profile::profile3']
}

The lookup works and classes are added to the catalog however I am unsure how I can also automate the chaining mechanism to ensure they run in correct order?

The reason for this change is I plan to onboard a large number of similar roles and being able to control these roles via a puppet fact and hiera is a hugely powerful mechanism.

The chains are essential so that my Windows build joins the domain and performs a number of build related profiles prior to running the additional application profiles.

Any help or pointers would be much appreciated.

1

Unfortunately, You can't pull in classes from Hiera like this and define relationships at the same time.

You could use stages to ensure that joining the domain comes first. Then, your application profiles come in the next stage afterwards.

https://puppet.com/docs/puppet/latest/lang_run_stages.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.