summaryrefslogtreecommitdiff
path: root/chef/lib/chef/knife/bootstrap
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2012-06-05 14:54:27 -0700
committerBryan McLellan <btm@opscode.com>2012-06-19 15:13:05 -0700
commit388fc86f4ce65a08f3fabf647e99a622a0a5375e (patch)
treef5413d27c0c815438c595668fba8f2ba5359b718 /chef/lib/chef/knife/bootstrap
parent9224673d61a5761b7d7ec627bcccd3f4a90083d7 (diff)
downloadchef-388fc86f4ce65a08f3fabf647e99a622a0a5375e.tar.gz
[CHEF-3160] Allow Ohai hints to be set when using knife-bootstrap.
Ohai hints allow the user to provide ohai with hints in the form of json files in /etc/chef/ohai/hints. These hints can then be used by plugins to provide better data in cases where automatic detection of conditions is difficult.
Diffstat (limited to 'chef/lib/chef/knife/bootstrap')
-rw-r--r--chef/lib/chef/knife/bootstrap/archlinux-gems.erb15
-rw-r--r--chef/lib/chef/knife/bootstrap/centos5-gems.erb13
-rw-r--r--chef/lib/chef/knife/bootstrap/chef-full.erb13
-rw-r--r--chef/lib/chef/knife/bootstrap/fedora13-gems.erb13
-rw-r--r--chef/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb13
-rw-r--r--chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb13
-rw-r--r--chef/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb13
7 files changed, 92 insertions, 1 deletions
diff --git a/chef/lib/chef/knife/bootstrap/archlinux-gems.erb b/chef/lib/chef/knife/bootstrap/archlinux-gems.erb
index 3a60eb477e..7525249d99 100644
--- a/chef/lib/chef/knife/bootstrap/archlinux-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/archlinux-gems.erb
@@ -28,6 +28,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
(
cat <<'EOP'
log_level :info
@@ -38,7 +51,7 @@ validation_client_name "<%= @chef_config[:validation_client_name] %>"
node_name "<%= @config[:chef_node_name] %>"
<% else -%>
# Using default node name (fqdn)
-<% end -%>
+<% end -%>
# ArchLinux follows the Filesystem Hierarchy Standard
file_cache_path "/var/cache/chef"
file_backup_path "/var/lib/chef/backup"
diff --git a/chef/lib/chef/knife/bootstrap/centos5-gems.erb b/chef/lib/chef/knife/bootstrap/centos5-gems.erb
index 9481178dda..1fe9831ef5 100644
--- a/chef/lib/chef/knife/bootstrap/centos5-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/centos5-gems.erb
@@ -41,6 +41,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
(
cat <<'EOP'
<%= config_content %>
diff --git a/chef/lib/chef/knife/bootstrap/chef-full.erb b/chef/lib/chef/knife/bootstrap/chef-full.erb
index 82d342bc19..6c0cd59fcc 100644
--- a/chef/lib/chef/knife/bootstrap/chef-full.erb
+++ b/chef/lib/chef/knife/bootstrap/chef-full.erb
@@ -44,6 +44,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
(
cat <<'EOP'
<%= config_content %>
diff --git a/chef/lib/chef/knife/bootstrap/fedora13-gems.erb b/chef/lib/chef/knife/bootstrap/fedora13-gems.erb
index 3c7c5cf5c6..cc8b6d7a48 100644
--- a/chef/lib/chef/knife/bootstrap/fedora13-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/fedora13-gems.erb
@@ -28,6 +28,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
(
cat <<'EOP'
<%= config_content %>
diff --git a/chef/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb b/chef/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb
index 929708707c..72905b4c93 100644
--- a/chef/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb
+++ b/chef/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb
@@ -28,6 +28,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
<% unless @chef_config[:validation_client_name] == "chef-validator" -%>
[ `grep -qx "validation_client_name \"<%= @chef_config[:validation_client_name] %>\"" /etc/chef/client.rb` ] || echo "validation_client_name \"<%= @chef_config[:validation_client_name] %>\"" >> /etc/chef/client.rb
<% end -%>
diff --git a/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb b/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb
index 6adc6212b7..4ed83ed10c 100644
--- a/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb
@@ -35,6 +35,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
(
cat <<'EOP'
<%= config_content %>
diff --git a/chef/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb b/chef/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb
index 700c47a6c0..af12ff2104 100644
--- a/chef/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb
+++ b/chef/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb
@@ -30,6 +30,19 @@ awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
rm /tmp/encrypted_data_bag_secret
<% end -%>
+<%# Generate Ohai Hints -%>
+<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
+mkdir -p /etc/chef/ohai/hints
+<% end -%>
+
+<% @chef_config[:knife][:hints].each do |name, hash| -%>
+(
+cat <<'EOP'
+<%= hash.to_json %>
+EOP
+) > /etc/chef/ohai/hints/<%= name %>.json
+<% end -%>
+
(
cat <<'EOP'
<%= config_content %>