From c0539d6e31967dad5cfb42956a84fc15c2ac3c69 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 19 Apr 2013 10:11:43 -0600 Subject: [PATCH] Warn if run list on Chef is empty, not error [GH-1620] --- CHANGELOG.md | 5 +++++ plugins/provisioners/chef/config/chef_client.rb | 2 -- plugins/provisioners/chef/config/chef_solo.rb | 2 -- plugins/provisioners/chef/provisioner/chef_client.rb | 4 ++++ plugins/provisioners/chef/provisioner/chef_solo.rb | 4 ++++ templates/locales/en.yml | 3 ++- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c804d4bb..6b172ad90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## 1.2.2 (unreleased) +IMPROVEMENTS: + + - No longer an error if the Chef run list is empty. It is now + a warning. [GH-1620] + BUG FIXES: - `vagrant package --base` works again. [GH-1615] diff --git a/plugins/provisioners/chef/config/chef_client.rb b/plugins/provisioners/chef/config/chef_client.rb index aa9cff1b3..32d7ccef8 100644 --- a/plugins/provisioners/chef/config/chef_client.rb +++ b/plugins/provisioners/chef/config/chef_client.rb @@ -52,8 +52,6 @@ module VagrantPlugins !chef_server_url || chef_server_url.strip == "" errors << I18n.t("vagrant.config.chef.validation_key_path") if \ !validation_key_path - errors << I18n.t("vagrant.config.chef.run_list_empty") if \ - @run_list && @run_list.empty? { "chef client provisioner" => errors } end diff --git a/plugins/provisioners/chef/config/chef_solo.rb b/plugins/provisioners/chef/config/chef_solo.rb index 3d832738d..2268dccb5 100644 --- a/plugins/provisioners/chef/config/chef_solo.rb +++ b/plugins/provisioners/chef/config/chef_solo.rb @@ -61,8 +61,6 @@ module VagrantPlugins errors = _detected_errors errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \ !cookbooks_path || [cookbooks_path].flatten.empty? - errors << I18n.t("vagrant.config.chef.run_list_empty") if \ - !run_list || run_list.empty? { "chef solo provisioner" => errors } end diff --git a/plugins/provisioners/chef/provisioner/chef_client.rb b/plugins/provisioners/chef/provisioner/chef_client.rb index 549f5a7f8..d14a6862c 100644 --- a/plugins/provisioners/chef/provisioner/chef_client.rb +++ b/plugins/provisioners/chef/provisioner/chef_client.rb @@ -58,6 +58,10 @@ module VagrantPlugins end def run_chef_client + if @config.run_list && @config.run_list.empty? + @machine.ui.warn(I18n.t("vagrant.chef_run_list_empty")) + end + command_env = @config.binary_env ? "#{@config.binary_env} " : "" command_args = @config.arguments ? " #{@config.arguments}" : "" command = "#{command_env}#{chef_binary_path("chef-client")} -c #{@config.provisioning_path}/client.rb -j #{@config.provisioning_path}/dna.json #{command_args}" diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index 584acbae7..c0ce268a0 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -135,6 +135,10 @@ module VagrantPlugins end def run_chef_solo + if @config.run_list && @config.run_list.empty? + @machine.ui.warn(I18n.t("vagrant.chef_run_list_empty")) + end + command_env = @config.binary_env ? "#{@config.binary_env} " : "" command_args = @config.arguments ? " #{@config.arguments}" : "" command = "#{command_env}#{chef_binary_path("chef-solo")} -c #{@config.provisioning_path}/solo.rb -j #{@config.provisioning_path}/dna.json #{command_args}" diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 1500dff59..6e76308c8 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -25,6 +25,8 @@ en: CFEngine running in "single run" mode. Will execute one file. cfengine_single_run_execute: |- Executing run file for CFEngine... + chef_run_list_empty: |- + Warning: Chef solo run list is empty. This may not be what you want. cfengine_config: classes_array: |- @@ -569,7 +571,6 @@ en: cookbooks_path_empty: "Must specify a cookbooks path for chef solo." cookbooks_path_missing: |- Cookbook path doesn't exist: %{path} - run_list_empty: "Run list must not be empty." server_url_empty: "Chef server URL must be populated." validation_key_path: "Validation key path must be valid path to your chef server validation key." loader: