Created
January 6, 2012 17:45
-
-
Save jbz/1571626 to your computer and use it in GitHub Desktop.
Setting up chef-client using userdata bootstrap scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"run_list": [ | |
"recipe[chef-client::config]", | |
"recipe[chef-client::service]", | |
"recipe[chef-client::delete_validation]", | |
"recipe[runit]", | |
"role[locke-validation-app]" | |
], | |
"chef_client": { | |
"server_url": "https://api.opscode.com/organizations/mdsol", | |
"validation_client_name": "mdsol-validator", | |
"environment": "candidate" | |
}, | |
"chef_packages": { "chef": {"version": "0.10.0" }} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write chef-client config | |
echo "Writing client configuration..." >>$BOOTLOG | |
NODE_NAME=<%= [project_name, stage_name, role]*'.' %>.`curl -s http://169.254.169.254/1.0/meta-data/instance-id/` | |
ATTRIBUTES_FILE=/etc/chef/attributes.json | |
cat > /etc/chef/client.rb <<EOF | |
node_name '$NODE_NAME' | |
log_level :info | |
log_location '/var/log/chef-client.log' | |
chef_server_url '<%= chef_api_url %>' | |
validation_client_name '<%= chef_validator_name %>' | |
json_attribs '$ATTRIBUTES_FILE' | |
environment '<%=chef_environment_name %>' | |
EOF | |
# Set roles for first chef run | |
echo "Writing node runlist..." >>$BOOTLOG | |
cat > $ATTRIBUTES_FILE <<EOF | |
{ | |
"run_list": [ | |
"recipe[chef-client::config]", | |
"recipe[chef-client::service]", | |
"recipe[chef-client::delete_validation]", | |
"recipe[runit]", | |
"<%= chef_role_as_runlist %>" | |
], | |
"chef_client": { | |
"server_url": "<%= chef_api_url %>", | |
"validation_client_name": "<%= chef_validator_name %>", | |
"environment": "<%=chef_environment_name %>" | |
}, | |
"chef_packages": { "chef": {"version": "${CHEF_VERSION}" }} | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment