Created
April 17, 2014 18:27
-
-
Save domcleal/11003111 to your computer and use it in GitHub Desktop.
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
# Chef configuration snippet | |
# | |
# Uses the following parameters: | |
# - chef-validation-key: PEM-formatted validation key | |
# - chef-url: URL to the Chef server, e.g. https://chef.example.com | |
# - chef-runlist: comma-separated runlist, e.g. role[bootstrap],role[base] | |
# - chef: when 'true', runs this snippet | |
<% if @host.param_true?('chef') %> | |
curl -L https://www.opscode.com/chef/install.sh | bash | |
chef-client -v | |
/opt/chef/embedded/bin/gem install chef_handler_foreman | |
mkdir -p /etc/chef | |
if [ ! -e /etc/chef/validation.pem ]; then | |
cat > /etc/chef/validation.pem << EOF | |
<%= @host.params['chef-validation-key'] %> | |
EOF | |
fi | |
cat > /etc/chef/client.rb << EOF | |
log_level :auto | |
log_location STDOUT | |
chef_server_url "<%= @host.params['chef-url'] %>" | |
validation_client_name "chef-validator" | |
require 'chef_handler_foreman' | |
foreman_server_options :url => "<%= Setting['foreman_url'] %>" | |
foreman_facts_upload true | |
foreman_reports_upload true | |
EOF | |
cat > /etc/chef/bootstrap.json << EOF | |
{"run_list": <%= @host.params['chef-runlist'].split(',').inspect %> } | |
EOF | |
chef-client -j /etc/chef/bootstrap.json | |
<% end -%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you want to use with safe_mode rendering enabled, change
Setting['foreman_url']
toforeman_url
on line 28