lib/itamae/mitsurin/itamae_task.rb in itamae-mitsurin-0.3 vs lib/itamae/mitsurin/itamae_task.rb in itamae-mitsurin-0.4
- old
+ new
@@ -100,11 +100,11 @@
puts e.class.to_s + ", " + e.backtrace[0].to_s
puts "nodefile or environments error, nodefile:#{node_file} reason:#{e.message}"
exit 1
end
- # get recipe attr
+ # get recipes attr
recipe_attr_file = []
recipes.each do |recipe_h|
if recipe_h["#{recipe_h.keys.join}"].nil?
recipe_attr_file.insert 0,
Dir.glob("site-cookbooks/**/#{recipe_h.keys.join}/attributes/default.json")
@@ -114,45 +114,47 @@
end
end
recipe_attr_file.flatten!
- # recipe attr other=env
+ # recipes attr other=env
recipe_env_h_a = []
recipe_attr_file.each do |file|
recipe_h = JSON.parse(File.read(file), symbolize_names: true)
recipe_env_h_a << recipe_h.deep_merge(env_h)
end
- # recipe attr other=recipes
+ # recipe attr other=recipes_env
moto = recipe_env_h_a[0]
recipe_env_h_a.each {|hash| moto.deep_merge!(hash)}
recipe_env_h = moto
if recipe_env_h.nil?
- # node attr other=env
+ # env attr other=node
node_env_h = env_h.deep_merge(node_h)
node_env_j = jq node_env_h
write_json(bname) {|file| file.puts node_env_j}
else
- # node attr other=recipe_env
+ # recipe_env attr other=node
recipe_env_node_h = recipe_env_h.deep_merge(node_h)
recipe_env_node_j = jq recipe_env_node_h
write_json(bname) {|file| file.puts recipe_env_node_j}
end
recipes << {'_base' => nil}
node_property = JSON.parse(File.read("tmp-nodes/#{bname}.json"), symbolize_names: true)
node = node_property[:environments][:hostname]
ssh_user = node_property[:environments][:ssh_user]
ssh_password = node_property[:environments][:ssh_password]
+ sudo_password = node_property[:environments][:sudo_password]
ssh_port = node_property[:environments][:ssh_port]
ssh_key = node_property[:environments][:ssh_key]
ENV['TARGET_HOST'] = node
ENV['NODE_FILE'] = node_file
ENV['SSH_PASSWORD'] = ssh_password
+ ENV['SUDO_PASSWORD'] = sudo_password
command = "bundle exec itamae ssh"
command << " -h #{node}"
command << " -u #{ssh_user}"
command << " -p #{ssh_port}"
@@ -176,10 +178,10 @@
end
command_recipe.sort_by! {|item| File.dirname(item)}
command << command_recipe.join
color.echos(:red ,%!Run Itamae to \"#{bname}\"!)
- color.echos(:blue, %!Set Roles to \"#{get_roles(node_file).join(", ")}\"!)
+ color.echos(:blue, %!Role List to \"#{get_roles(node_file).join(", ")}\"!)
run_list_noti = []
command_recipe.each {|c_recipe| run_list_noti << c_recipe.split("/") [2]}
color.echos(:green, %!Run List to \"#{run_list_noti.uniq.join(", ")}\"!)
puts color.echos(:white, %!#{command}!)
st = system command