0

how to manage auto scaling instances with puppet? i want to configure s/w stack based on type of instances (e.g if web then Apache or Nginx and if app then java or php)

1 Answer 1

1

This can be easily managed with hiera. On bootstrap of the server, you can write a custom fact which hiera will use to apply the relevant modules to your server. In your cloud-init user data script you can add something like this:

echo 'role=apache_web' > /etc/facter/facts.d/role.txt

You can then use that role in hiera's hierarchy. Here is an example section for hiera.yml:

:hierarchy:
  - "nodes/%{::trusted.certname}"
  - "environment/%{::environment}"
  - "role/%{::server_role}"
  - "common"

Your hiera file for you apache_web role would be hieradata/role/apache_web.yaml in your control repo. For Puppet 4, the absolute path should be /etc/puppetlabs/code/environments/$ENVIRONMENT/hieradata/role/apache_web.yaml. Here is an example:

---
classes:
  - 'apache'
  - 'myinternalmodule'

To tie everything together, have all of your nodes use the same site.pp which includes:

hiera_include('classes')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .