We use the Cloud-init system built into Ubuntu for our Amazon VPC instances. When starting a new instance we pass it User-data which contains commands in Cloud-config format that sets the hostname and domain, adds the puppetlabs repo, updates the package cache, installs puppet and enters some values such as the certname and servername in the puppet.conf file.
#cloud-config
manage_etc_hosts: true
hostname: <hostname>
fqdn: <hostname>.example.com
apt_sources:
- source: "deb http://apt.puppetlabs.com $RELEASE main dependencies"
keyid: 4BD6EC30
filename: puppetlabs.list
apt_update: true
apt_upgrade: true
packages:
- puppet
puppet:
conf:
agent:
server: "puppet.example.com"
certname: "%i.<hostname>.us-east-1.vpc.aws"
The %i is automatically replaced with the instance-id. Our deployment is small enough 10-20 instances) that for us the certname contains enough information to identify the machine. You can easily extend this to put some custom facts {1} on the machine, like DC, AZ, which Puppet would receive automatically from Facter on every run. In fact, I'm working on that. Search Google for "cloud-init facter" and you'll get the idea.
A role {2} is then assigned to the new host via an ENC (e.g. queue_worker, solr_server or webserver_drupal). Each role lists a number of profiles {3} that describe the actual services needed (e.g. php55, apache, ntp, logstash_shipper, etc.). For example, the ntp_client profile uses the ntp module and values from Hiera to set up NTP. Check out the roles-profiles pattern if you're not familiar, which is becoming a standard design in Puppet-land.
Use Hiera to configure your modules depending on those facts, things like which NTP-servers should the ntp module use, to which RabbitMQ server should Logstash send its logs, which PHP-modules does this platform require, etc.
The Extending Puppet book explains the details better than I can, but hopefully this helped you on the way. The main thing in bootstrapping for us was using User-Data and Cloud-init to get things rolling. The remainder is standard Puppet stuff (i.e. Facter, Hiera, Puppet).
Regards, Martijn
Op dinsdag 26 augustus 2014 21:41:01 UTC+2 schreef Alex Demitri: