summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-02-18 09:07:37 +0000
committerThom May <thom@may.lt>2016-02-18 09:07:37 +0000
commit320389bf316d461ffc874ec4041999bffbac590a (patch)
tree60f35b64c110f125a3d9bc6fd65eb594b35749e4
parenta07b8022e790c025265f8859b5e04ac5116e7683 (diff)
parentd038cf5a74267e02136d38407bbaa188754e5830 (diff)
downloadchef-320389bf316d461ffc874ec4041999bffbac590a.tar.gz
Merge pull request #4316 from josb/master
chef-client: add --[no]skip-cookbook-sync option
-rw-r--r--distro/common/markdown/man8/chef-client.mkd2
-rw-r--r--lib/chef/application/client.rb5
-rw-r--r--lib/chef/cookbook/synchronizer.rb4
-rw-r--r--lib/chef/shell.rb5
4 files changed, 16 insertions, 0 deletions
diff --git a/distro/common/markdown/man8/chef-client.mkd b/distro/common/markdown/man8/chef-client.mkd
index ffe444ecf2..7506e3b925 100644
--- a/distro/common/markdown/man8/chef-client.mkd
+++ b/distro/common/markdown/man8/chef-client.mkd
@@ -40,6 +40,8 @@ __chef-client__ _(options)_
Set the PID file location, defaults to /tmp/chef-client.pid
* `--once`:
Cancel any interval or splay options, run chef once and exit
+ * `--skip-cookbook-sync`:
+ Skip cookbook synchronization
* `-v`, `--version`:
Show chef version
* `-h`, `--help`:
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 1a7d8d046d..9ec553fb8a 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -285,6 +285,11 @@ class Chef::Application::Client < Chef::Application
:description => "DANGEROUS: does what it says, only useful with --recipe-url",
:boolean => true
+ option :skip_cookbook_sync,
+ :long => "--[no-]skip-cookbook-sync",
+ :description => "Use cached cookbooks without overwriting local differences from the server",
+ :boolean => false
+
IMMEDIATE_RUN_SIGNAL = "1".freeze
attr_reader :chef_client_json
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index e8b90a45c3..ec388746e9 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -263,6 +263,10 @@ class Chef
end
def cached_copy_up_to_date?(local_path, expected_checksum)
+ if Chef::Config[:skip_cookbook_sync]
+ Chef::Log.warn "skipping cookbook synchronization! DO NOT LEAVE THIS ENABLED IN PRODUCTION!!!"
+ return true
+ end
if cache.has_key?(local_path)
current_checksum = CookbookVersion.checksum_cookbook_file(cache.load(local_path, false))
expected_checksum == current_checksum
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index 72081b18df..aad5c49d00 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -265,6 +265,11 @@ FOOTER
:description => "Replace current run list with specified items",
:proc => lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) } }
+ option :skip_cookbook_sync,
+ :long => "--[no-]skip-cookbook-sync",
+ :description => "Use cached cookbooks without overwriting local differences from the server",
+ :boolean => false
+
def self.print_help
instance = new
instance.parse_options([])