Skip to content

Instantly share code, notes, and snippets.

@przygode
Created October 29, 2012 00:53
Show Gist options
  • Save przygode/3970766 to your computer and use it in GitHub Desktop.
Save przygode/3970766 to your computer and use it in GitHub Desktop.
chefclient properties
"Properties": {
"SecurityGroups": [ { "Ref": "AppServerAccess" } ],
"ImageId": {
"Fn::FindInMap": [
"AWSRegionArch2AMI",
{ "Ref": "AWS::Region" },
{ "Fn::FindInMap": [
"AWSInstanceType2Arch",
{ "Ref": "InstanceType" },
"Arch"
]
}
]
},
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash -v\n",
"function error_exit\n",
"{\n",
" cfn-signal -e 1 -r \"$1\" '",
{
"Ref": "ChefClientWaitHandle"
},
"'\n",
" exit 1\n",
"}\n",
"apt-get update; apt-get upgrade -y; apt-get -y remove apparmor libapparmor1 ; apt-get -y install python-setuptools\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-1.0-6.tar.gz\n",
"cfn-init --region ",
{
"Ref": "AWS::Region"
},
" -s ",
{
"Ref": "AWS::StackName"
},
" -r ChefClient ",
" --access-key ",
{
"Ref": "HostKeys"
},
" --secret-key ",
{
"Fn::GetAtt": [
"HostKeys",
"SecretAccessKey"
]
},
" --region ",
{
"Ref": "AWS::Region"
},
" || error_exit 'Failed to run cfn-init'\n",
"# Fixup path and links for the bootstrap script\n",
"export PATH=$PATH:/var/lib/gems/1.8/bin\n",
"s3cmd -c /home/ubuntu/.s3cfg get s3://",
{
"Ref": "StrataluxBucket"
},
"/chef_init.rb /etc/chef/chef_init.rb > /tmp/get_chef_init.log 2>&1 || error_exit 'Failed to get Chef initialization script.'\n",
"ruby /etc/chef/chef_init.rb ",
{
"Ref": "DomainName"
},
" ",
{
"Ref": "ChefEnvironment"
},
" ",
{
"Ref": "ChefOrganization"
},
" >> /tmp/get_chef_init.log 2>&1 || error_exit 'Failed to run chef_init script.'\n",
"# Fixup the server URL in client.rb\n",
"s3cmd -c /home/ubuntu/.s3cfg get s3://",
{
"Ref": "StrataluxBucket"
},
"/validation.pem /etc/chef/validation.pem > /tmp/get_validation_key.log 2>&1 || error_exit 'Failed to get Chef Server validation key'\n",
"s3cmd -c /home/ubuntu/.s3cfg get s3://",
{
"Ref": "StrataluxBucket"
},
"/encrypted_data_bag_secret /etc/chef/encrypted_data_bag_secret > /tmp/encrypted_data_bag_secret.log 2>&1 || error_exit 'Failed to get Chef encrypted data bag secret.'\n",
"chmod 600 /etc/chef/encrypted_data_bag_secret \n",
"chef-client -j /etc/chef/first-boot.json > /tmp/initialize_client.log 2>&1 || error_exit 'Failed to initialize host via chef client' \n",
"# If all went well, signal success\n",
"cfn-signal -e $? -r 'Chef Server configuration' '",
{
"Ref": "ChefClientWaitHandle"
},
"'\n"
]
]
}
},
"KeyName": {
"Ref": "KeyName"
},
"InstanceType": {
"Ref": "InstanceType"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment