This is a repository of useful functions for integrating puppet with Amazon Web Services. These custom parser functions are executed on the puppet master during catalog compilation The gem and aws credentials need only be installed on the master.
The files in functions should be placed in your puppet config tree in a module at lib/puppet/parser/functions. The files in facter should be placed in lib/facter.
- fog gem
- curl
- facter ec2_meta_data lib
There should be a yaml file at '/etc/puppet/fog_cred' in the format:
:default:
:aws_access_key_id: XXXXXXXXXXXXXXXXX
:aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXX
returns a hash of the internal IP addresses of all instances matching the aws resource tag key, value, or key => value pair passed in. Useful for load balancer configs.
Registers the instance ID with the elb matching the passed name
creates a route53 dns record (all dns names must be passed with a . at the end)
returns the Etag (md5) of an s3 object
returns a curl command and signed url referencing the specified s3 object
define s3get ($bucket='puppet-filesource', $cwd='/tmp', $expires=30) {
$file_checksum = s3getEtag($bucket, $key)
exec { "s3getcurl[$bucket][$title][$name]":
cwd => $cwd,
unless => "echo \"$file_checksum $name\" | md5sum -c --status",
command => s3getcurl($bucket, $title, $name, $expires),
}
}