Skip to content

Instantly share code, notes, and snippets.

@devsecfranklin
Last active January 10, 2018 05:15
Show Gist options
  • Save devsecfranklin/0b7cac1972e2fba7aae8676b4e062a02 to your computer and use it in GitHub Desktop.
Save devsecfranklin/0b7cac1972e2fba7aae8676b4e062a02 to your computer and use it in GitHub Desktop.

Navigate to:

code/environments/production/modules/role/manifests

Create a new role manifest

Just copy the old one because we're lazy. We can always add/remove profile manifests from the role later if needed.

cp iac_node.pp franklin_node.pp

Update role.rb

Edit the file: code/environments/production/modules/profile/lib/facter

Add a "when" clause for the new node, something like this:

# <ENVIRONMENTS DIRECTORY>/<ENVIRONMENT>/modules/profile/lib/facter/role.rb
Facter.add(:role) do
  # Retrieve hostname and assign role base on it        
  setcode do
    hname = Facter.value(:hostname)
    case hname
    when /^airlock/
      'airlock'
    when /^franklin_node/
      'franklin_node'
    else
      'iac_node'
    end
  end
end

Use Terraform to Create a Host with this Hostname

Edit the hostname to match the new "when" statement and this role should be applied to it.

So basically add a new host in iac_workshop/terraform/aws/machines.tf.

Run the terraform.

Verify it

Log in to the host ane run this command. Verify the role is correct.

puppet facts show | grep role
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment