From 3ca6231a7908e2c54c679c187a46ae10dfe21396 Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Tue, 15 Sep 2015 09:57:32 -0700 Subject: Show policyfile attributes in node presenter --- lib/chef/knife/core/node_presenter.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb index d1aab592ef..d9ea8c7669 100644 --- a/lib/chef/knife/core/node_presenter.rb +++ b/lib/chef/knife/core/node_presenter.rb @@ -67,7 +67,12 @@ class Chef result = {} result["name"] = node.name - result["chef_environment"] = node.chef_environment + if node.policy_name.nil? && node.policy_group.nil? + result["chef_environment"] = node.chef_environment + else + result["policy_name"] = node.policy_name + result["policy_group"] = node.policy_group + end result["run_list"] = node.run_list result["normal"] = node.normal_attrs @@ -95,11 +100,29 @@ class Chef summarized=<<-SUMMARY #{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)} +SUMMARY + show_policy = !(node.policy_name.nil? && node.policy_group.nil?) + if show_policy + summarized << <<-POLICY +#{key('Policy Name:')} #{node.policy_name} +#{key('Policy Group:')} #{node.policy_group} +POLICY + else + summarized << <<-ENV #{key('Environment:')} #{node.chef_environment} +ENV + end + summarized << <<-SUMMARY #{key('FQDN:')} #{node[:fqdn]} #{key('IP:')} #{ip} #{key('Run List:')} #{node.run_list} +SUMMARY + unless show_policy + summarized << <<-ROLES #{key('Roles:')} #{Array(node[:roles]).join(', ')} +ROLES + end + summarized << <<-SUMMARY #{key('Recipes:')} #{Array(node[:recipes]).join(', ')} #{key('Platform:')} #{node[:platform]} #{node[:platform_version]} #{key('Tags:')} #{Array(node[:tags]).join(', ')} -- cgit v1.2.1