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)
Asked
Active
Viewed 844 times
1 Answers
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')

jordanm
- 889
- 5
- 9