summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-08-27 15:20:44 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-08-28 10:53:34 -0700
commit72562e52a3fdc325f1bfe12d42f75a12a8c7307d (patch)
tree5568278a6d481e11d336e7746dde1815445c3428 /lib/chef
parentdd0009d7e77f192cadb1632f2159a6dbc880980f (diff)
downloadchef-72562e52a3fdc325f1bfe12d42f75a12a8c7307d.tar.gz
fail on interval runs on windows
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/application/base.rb7
-rw-r--r--lib/chef/application/client.rb8
-rw-r--r--lib/chef/application/solo.rb8
3 files changed, 20 insertions, 3 deletions
diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb
index fea3d844ce..c5bff9874e 100644
--- a/lib/chef/application/base.rb
+++ b/lib/chef/application/base.rb
@@ -340,6 +340,13 @@ class Chef::Application::Base < Chef::Application
private
+ def windows_interval_error_message
+ "Windows #{Chef::Dist::PRODUCT} interval runs are not supported in #{Chef::Dist::PRODUCT} 15 and later." +
+ "\nConfiguration settings:" +
+ ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
+ "\nPlease manage #{Chef::Dist::PRODUCT} as a scheduled task instead."
+ end
+
def unforked_interval_error_message
"Unforked #{Chef::Dist::PRODUCT} interval runs are disabled by default." +
"\nConfiguration settings:" +
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 0fc5ca7711..890ecbd385 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -128,8 +128,12 @@ class Chef::Application::Client < Chef::Application::Base
Chef::Config[:client_fork] = !!Chef::Config[:interval]
end
- if !Chef::Config[:client_fork] && Chef::Config[:interval] && !Chef::Platform.windows?
- Chef::Application.fatal!(unforked_interval_error_message)
+ if Chef::Config[:interval]
+ if Chef::Platform.windows?
+ Chef::Application.fatal!(windows_interval_error_message)
+ elsif !Chef::Config[:client_fork]
+ Chef::Application.fatal!(unforked_interval_error_message)
+ end
end
if Chef::Config[:json_attribs]
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index bce95c2841..da9ec7f566 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -102,7 +102,13 @@ class Chef::Application::Solo < Chef::Application::Base
Chef::Config[:client_fork] = !!Chef::Config[:interval]
end
- Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
+ if Chef::Config[:interval]
+ if Chef::Platform.windows?
+ Chef::Application.fatal!(windows_interval_error_message)
+ elsif !Chef::Config[:client_fork]
+ Chef::Application.fatal!(unforked_interval_error_message)
+ end
+ end
if Chef::Config[:recipe_url]
cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| Pathname.new(e).cleanpath.to_s =~ %r{/cookbooks/*$} }