Skip to content

Commit

Permalink
Generating networking config JSON for the hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro committed Jan 24, 2014
1 parent 065c147 commit 0de22b6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions run_roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
exit unless current_host

begin
roles = Chef::DataBagItem.load(:node, current_host)["role"]
node = Chef::DataBagItem.load(:node, current_host)
roles = node["role"]
rescue
puts "Databag configuration for host #{ARGV[0]} not found"
exit
Expand All @@ -27,7 +28,14 @@
end

File.open("#{current_path}/#{current_host}.json", "w") do |f|
f.print({ run_list: run_lists.compact.uniq }.to_json)
f.print({
run_list: run_lists.compact.uniq, # Run list for the host
net: { # Generate networking infor for hostname cookbook
hostname: node["hostname"] ,
FQDN: node["fqdn"],
IP: node["ipaddress"]
}
}.to_json)
end

cmd = "cd #{current_path} && chef-solo --config solo.rb --json-attributes #{current_host}.json"
Expand Down

0 comments on commit 0de22b6

Please sign in to comment.