From e4cdb473bd1a7ad666ddc9f398c661f62a9cfb2c Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 28 Jul 2015 12:41:51 -0400 Subject: [PATCH 1/6] Bring back `nodes_path` support for the Chef Zero provisioner --- plugins/provisioners/chef/config/chef_zero.rb | 7 +++++++ plugins/provisioners/chef/provisioner/chef_solo.rb | 2 ++ plugins/provisioners/chef/provisioner/chef_zero.rb | 1 + templates/provisioners/chef_zero/zero.erb | 4 ++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/provisioners/chef/config/chef_zero.rb b/plugins/provisioners/chef/config/chef_zero.rb index d28de3dc9..9b1daf1a5 100644 --- a/plugins/provisioners/chef/config/chef_zero.rb +++ b/plugins/provisioners/chef/config/chef_zero.rb @@ -17,6 +17,10 @@ module VagrantPlugins # @return [String] attr_accessor :environments_path + # The path where nodes are stored on disk. + # @return [String] + attr_accessor :nodes_path + # The path where roles are stored on disk. # @return [String] attr_accessor :roles_path @@ -31,6 +35,7 @@ module VagrantPlugins @cookbooks_path = UNSET_VALUE @data_bags_path = UNSET_VALUE @environments_path = UNSET_VALUE + @nodes_path = UNSET_VALUE @roles_path = UNSET_VALUE @synced_folder_type = UNSET_VALUE end @@ -47,6 +52,7 @@ module VagrantPlugins end @data_bags_path = [] if @data_bags_path == UNSET_VALUE + @nodes_path = [] if @nodes_path == UNSET_VALUE @roles_path = [] if @roles_path == UNSET_VALUE @environments_path = [] if @environments_path == UNSET_VALUE @environments_path = [@environments_path].flatten @@ -54,6 +60,7 @@ module VagrantPlugins # Make sure the path is an array. @cookbooks_path = prepare_folders_config(@cookbooks_path) @data_bags_path = prepare_folders_config(@data_bags_path) + @nodes_path = prepare_folders_config(@nodes_path) @roles_path = prepare_folders_config(@roles_path) @environments_path = prepare_folders_config(@environments_path) diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index f3b52f178..14ee5747c 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -33,12 +33,14 @@ module VagrantPlugins @role_folders = expanded_folders(@config.roles_path, "roles") @data_bags_folders = expanded_folders(@config.data_bags_path, "data_bags") @environments_folders = expanded_folders(@config.environments_path, "environments") + @node_folders = expanded_folders(@config.nodes_path, "nodes") existing = synced_folders(@machine, cached: true) share_folders(root_config, "csc", @cookbook_folders, existing) share_folders(root_config, "csr", @role_folders, existing) share_folders(root_config, "csdb", @data_bags_folders, existing) share_folders(root_config, "cse", @environments_folders, existing) + share_folders(root_config, "csn", @node_folders, existing) end def provision diff --git a/plugins/provisioners/chef/provisioner/chef_zero.rb b/plugins/provisioners/chef/provisioner/chef_zero.rb index 48078a09f..70fff6854 100644 --- a/plugins/provisioners/chef/provisioner/chef_zero.rb +++ b/plugins/provisioners/chef/provisioner/chef_zero.rb @@ -44,6 +44,7 @@ module VagrantPlugins local_mode: true, enable_reporting: false, cookbooks_path: guest_paths(@cookbook_folders), + nodes_path: guest_paths(@node_folders), roles_path: guest_paths(@role_folders), data_bags_path: guest_paths(@data_bags_folders).first, environments_path: guest_paths(@environments_folders).first, diff --git a/templates/provisioners/chef_zero/zero.erb b/templates/provisioners/chef_zero/zero.erb index 29de30d23..8c4b76407 100644 --- a/templates/provisioners/chef_zero/zero.erb +++ b/templates/provisioners/chef_zero/zero.erb @@ -31,8 +31,8 @@ environment "<%= environment %>" chef_zero.enabled true local_mode true <% end -%> -<% if node_path -%> -node_path <%= node_path.inspect %> +<% if nodes_path -%> +node_path <%= nodes_path.inspect %> <% end -%> <% if formatter %> From 15ec95328ad962ee4326e3cdcaca376af7cea8e0 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 28 Jul 2015 13:24:39 -0400 Subject: [PATCH 2/6] Update test --- .../plugins/provisioners/chef/config/chef_zero_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb b/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb index 2f9cd82aa..9a1f98cd6 100644 --- a/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb +++ b/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb @@ -50,6 +50,14 @@ describe VagrantPlugins::Chef::Config::ChefZero do end end + describe "#nodes_path" do + it "defaults to an empty array" do + subject.finalize! + expect(subject.nodes_path).to be_a(Array) + expect(subject.nodes_path).to be_empty + end + end + describe "#synced_folder_type" do it "defaults to nil" do subject.finalize! From 01f0dccbdc3f26842ed74a018f7cf828e9e19234 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 28 Jul 2015 13:25:25 -0400 Subject: [PATCH 3/6] Update documentation for Chef Zero `nodes_path` --- website/docs/source/v2/provisioning/chef_zero.html.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/docs/source/v2/provisioning/chef_zero.html.md b/website/docs/source/v2/provisioning/chef_zero.html.md index 4f35f362a..bd2527fc9 100644 --- a/website/docs/source/v2/provisioning/chef_zero.html.md +++ b/website/docs/source/v2/provisioning/chef_zero.html.md @@ -41,6 +41,9 @@ available below this section. * `environments_path` (string) - A path where environment definitions are located. By default, no environments folder is set. +* `nodes_path` (string or array) - A list of paths where node objects (in JSON format) are stored. By default, no + nodes path is set. + * `environment` (string) - The environment you want the Chef run to be a part of. This requires Chef 11.6.0 or later, and that `environments_path` is set. From fd593a85b7034229e2428e2caa1a38355f0057e8 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Sun, 27 Sep 2015 23:23:28 -0400 Subject: [PATCH 4/6] Add `nodes_path` support for the Chef-Solo provisioner --- plugins/provisioners/chef/config/chef_solo.rb | 7 +++++++ plugins/provisioners/chef/provisioner/chef_solo.rb | 2 ++ templates/provisioners/chef_solo/solo.erb | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/provisioners/chef/config/chef_solo.rb b/plugins/provisioners/chef/config/chef_solo.rb index ee4a2ac2e..a9630a7b8 100644 --- a/plugins/provisioners/chef/config/chef_solo.rb +++ b/plugins/provisioners/chef/config/chef_solo.rb @@ -17,6 +17,10 @@ module VagrantPlugins # @return [String] attr_accessor :environments_path + # The path where nodes are stored on disk. + # @return [String] + attr_accessor :nodes_path + # A URL download a remote recipe from. Note: you should use chef-apply # instead. # @@ -39,6 +43,7 @@ module VagrantPlugins @cookbooks_path = UNSET_VALUE @data_bags_path = UNSET_VALUE @environments_path = UNSET_VALUE + @nodes_path = UNSET_VALUE @recipe_url = UNSET_VALUE @roles_path = UNSET_VALUE @synced_folder_type = UNSET_VALUE @@ -86,6 +91,7 @@ module VagrantPlugins end @data_bags_path = [] if @data_bags_path == UNSET_VALUE + @nodes_path = [] if @nodes_path == UNSET_VALUE @roles_path = [] if @roles_path == UNSET_VALUE @environments_path = [] if @environments_path == UNSET_VALUE @environments_path = [@environments_path].flatten @@ -93,6 +99,7 @@ module VagrantPlugins # Make sure the path is an array. @cookbooks_path = prepare_folders_config(@cookbooks_path) @data_bags_path = prepare_folders_config(@data_bags_path) + @nodes_path = prepare_folders_config(@nodes_path) @roles_path = prepare_folders_config(@roles_path) @environments_path = prepare_folders_config(@environments_path) end diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index 14ee5747c..1fc29da6e 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -19,6 +19,7 @@ module VagrantPlugins attr_reader :environments_folders attr_reader :cookbook_folders + attr_reader :node_folders attr_reader :role_folders attr_reader :data_bags_folders @@ -160,6 +161,7 @@ module VagrantPlugins { cookbooks_path: guest_paths(@cookbook_folders), recipe_url: @config.recipe_url, + nodes_path: guest_paths(@node_folders), roles_path: guest_paths(@role_folders), data_bags_path: guest_paths(@data_bags_folders).first, environments_path: guest_paths(@environments_folders).first diff --git a/templates/provisioners/chef_solo/solo.erb b/templates/provisioners/chef_solo/solo.erb index 25d3346b7..a3b01ed3b 100644 --- a/templates/provisioners/chef_solo/solo.erb +++ b/templates/provisioners/chef_solo/solo.erb @@ -31,8 +31,8 @@ environment "<%= environment %>" <% if local_mode -%> local_mode true <% end -%> -<% if node_path -%> -node_path <%= node_path.inspect %> +<% if nodes_path -%> +node_path <%= nodes_path.inspect %> <% end -%> http_proxy <%= http_proxy.inspect %> From c23610d70379f03ac27ba281356def7108aca868 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Sun, 27 Sep 2015 23:24:01 -0400 Subject: [PATCH 5/6] Update test --- .../plugins/provisioners/chef/config/chef_solo_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/plugins/provisioners/chef/config/chef_solo_test.rb b/test/unit/plugins/provisioners/chef/config/chef_solo_test.rb index d6a2a03af..2c699cbd2 100644 --- a/test/unit/plugins/provisioners/chef/config/chef_solo_test.rb +++ b/test/unit/plugins/provisioners/chef/config/chef_solo_test.rb @@ -57,6 +57,14 @@ describe VagrantPlugins::Chef::Config::ChefSolo do end end + describe "#nodes_path" do + it "defaults to an empty array" do + subject.finalize! + expect(subject.nodes_path).to be_a(Array) + expect(subject.nodes_path).to be_empty + end + end + describe "#synced_folder_type" do it "defaults to nil" do subject.finalize! From 8fb2e0b4a54f38a93c133928c630101aa55a7e3c Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Sun, 27 Sep 2015 23:24:40 -0400 Subject: [PATCH 6/6] Update documentation for Chef Solo `nodes_path` --- website/docs/source/v2/provisioning/chef_solo.html.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/docs/source/v2/provisioning/chef_solo.html.md b/website/docs/source/v2/provisioning/chef_solo.html.md index a7841b90e..a43232bed 100644 --- a/website/docs/source/v2/provisioning/chef_solo.html.md +++ b/website/docs/source/v2/provisioning/chef_solo.html.md @@ -42,6 +42,9 @@ available below this section. * `environments_path` (string) - A path where environment definitions are located. By default, no environments folder is set. +* `nodes_path` (string or array) - A list of paths where node objects (in JSON format) are stored. By default, no + nodes path is set. + * `environment` (string) - The environment you want the Chef run to be a part of. This requires Chef 11.6.0 or later, and that `environments_path` is set.