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