Skip to content

Instantly share code, notes, and snippets.

@darron
Created April 12, 2015 20:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darron/2cca61c563820186ea48 to your computer and use it in GitHub Desktop.
Save darron/2cca61c563820186ea48 to your computer and use it in GitHub Desktop.
AWS user-data to register with a Chef server. We are assuming that Chef is already installed during a previous AMI building phase.
#!/bin/bash
S3_BUCKET="where-your-validator-client-rb-and-json-are-stored"
ROLE="role-you-want-to-converge"
apt-get update
apt-get -y upgrade
# Get the validation.pem from S3
# This can only be done if the IAM profile the instance
# was launched with has access to the $S3_BUCKET.
s3cmd get s3://$S3_BUCKET/validation.pem /etc/chef/validation.pem
chmod 600 /etc/chef/validation.pem
# Write first-boot.json and client.rb
s3cmd get s3://$S3_BUCKET/first-boot/$ROLE.json /etc/chef/first-boot.json
s3cmd get s3://$S3_BUCKET/client.rb /etc/chef/client.rb
# Bootstrap Chef
chef-client -j /etc/chef/first-boot.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment