-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- templatized client.rb.erb - removed ec2 hints from bootstrap script - configurable http/https proxy for Chef - no longer pulling down gpg key for chef opscode apt repo. doesn't seem to be needed and breaks the bootstrap Change-Id: I492cb039f7d82df099748607d30308aa9e4e803c
- Loading branch information
1 parent
38082ab
commit 6f0a7f6
Showing
5 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require "ohai" | ||
require "json" | ||
|
||
# | ||
# Load configuration | ||
# | ||
|
||
def merge_safely hsh | ||
hsh.merge!( yield ) rescue Mash.new | ||
end | ||
|
||
def create_file_if_empty(filename, str) | ||
unless File.exists?(filename) | ||
puts "Populating #{filename}" ; | ||
File.open(filename, "w", 0600){|f| f.puts(str) } | ||
end | ||
end | ||
|
||
def present?(config, key) | ||
not config[key].to_s.empty? | ||
end | ||
|
||
# Start with a set of defaults | ||
chef_config = Mash.new | ||
|
||
merge_safely(chef_config) do | ||
{ | ||
'chef_server' => '<%= @chef_config[:chef_server_url] %>', | ||
'organization' => '<%= @chef_config[:organization] %>', | ||
'client_key' => "<%= @client_key %>", | ||
'node_name' => '<%= @server.full_name %>', | ||
'realm_name' => '<%= @server.realm_name %>', | ||
'cluster_name' => '<%= @server.cluster_name %>', | ||
'facet_name' => '<%= @server.facet_name %>', | ||
'facet_index' => '<%= @server.name %>', | ||
} | ||
end | ||
|
||
# | ||
# Configure chef run | ||
# | ||
|
||
log_level :info | ||
log_location STDOUT | ||
node_name chef_config["node_name"] if chef_config["node_name"] | ||
chef_server_url chef_config["chef_server"] if chef_config["chef_server"] | ||
validation_client_name chef_config["validation_client_name"] if chef_config["validation_client_name"] | ||
validation_key "/etc/chef/validation.pem" | ||
client_key "/etc/chef/client.pem" | ||
node_attrs_file "/etc/chef/first-boot.json" | ||
|
||
<%- if @server.selected_cloud.chef_http_proxy %> | ||
http_proxy '<%= @server.selected_cloud.chef_http_proxy %>' | ||
<%- end %> | ||
|
||
<%- if @server.selected_cloud.chef_http_proxy %> | ||
https_proxy '<%= @server.selected_cloud.chef_https_proxy %>' | ||
<%- end %> | ||
|
||
|
||
# If the client file is missing, write the validation key out so chef-client can register | ||
unless File.exists?(client_key) | ||
if present?(chef_config, "client_key") then create_file_if_empty(client_key, chef_config["client_key"]) | ||
elsif present?(chef_config, "validation_key") then create_file_if_empty(validation_key, chef_config["validation_key"]) | ||
else warn "Yikes -- I have no client key or validation key!!" | ||
end | ||
end | ||
|
||
reduced_chef_config = chef_config.reject{|k,v| k.to_s =~ /(_key|run_list)$/ } | ||
unless File.exists?(node_attrs_file) | ||
create_file_if_empty(node_attrs_file, JSON.pretty_generate(reduced_chef_config)) | ||
end | ||
json_attribs node_attrs_file | ||
|
||
Chef::Log.debug(JSON.generate(chef_config)) | ||
Chef::Log.info("=> chef client #{node_name} on #{chef_server_url} in cluster +#{chef_config["cluster_name"]}+") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,12 @@ set -e | |
echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list | ||
|
||
# Make sure that opscode chef is on the apt repo list. | ||
sudo mkdir -p /etc/apt/trusted.gpg.d | ||
gpg --keyserver keys.gnupg.net --recv-keys 83EF826A | ||
gpg --export [email protected] | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null | ||
|
||
# This key no longer seems to exist? Removing it doesn't seem to hurt | ||
# anything. -- Josh | ||
# sudo mkdir -p /etc/apt/trusted.gpg.d | ||
# gpg --keyserver keys.gnupg.net --recv-keys 83EF826A | ||
# gpg --export [email protected] | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null | ||
|
||
date > /etc/box_build_time | ||
|
||
|
@@ -102,11 +105,6 @@ cat <<'EOP' | |
EOP | ||
) > /etc/chef/first-boot.json | ||
|
||
# Ensure that EC2 images are recognized even inside VPC | ||
mkdir -p /etc/chef/ohai/hints/ | ||
touch /etc/chef/ohai/hints/ec2.json | ||
|
||
|
||
echo -e "`date` \n\n**** \n**** Adding chef client nonce script:\n****\n" | ||
|
||
cat > /etc/init.d/chef-client-nonce <<'EOP' | ||
|
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
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
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
6f0a7f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to drop in uninvited with comments out of nowhere. I found you could pull GPG key for chef repo from opscode directly. Not installing the key doesn't interfere with bootstrap, at any rate, just foregoes verification of chef packages installed thereafter.
#357
6f0a7f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! updated. apologies for not having time at the moment to look at your PR for master branch.
6f0a7f6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. Just happened by chance to notice duplicate work underway.