diff options
-rw-r--r-- | lib/chef/dsl/platform_introspection.rb | 7 | ||||
-rw-r--r-- | lib/chef/resource/file.rb | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb index 4ccdb34981..a0c2d33967 100644 --- a/lib/chef/dsl/platform_introspection.rb +++ b/lib/chef/dsl/platform_introspection.rb @@ -254,8 +254,11 @@ class Chef # === Returns # true:: if the current node is a docker container # false:: if the current node is not a docker container - def docker?(node) - ::File.exist?("/.dockerinit") || ::File.exist?("/.dockerenv") + def docker?(node = run_context.nil? ? nil : run_context.node) + # Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad, + # and that makes us sad too. + node && node[:virtualization] && node[:virtualization][:systems] && + node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest" end end diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb index b8c7bb73e9..71a8e946fd 100644 --- a/lib/chef/resource/file.rb +++ b/lib/chef/resource/file.rb @@ -50,7 +50,7 @@ class Chef allowed_actions :create, :delete, :touch, :create_if_missing property :path, String, name_property: true, identity: true - property :atomic_update, [ true, false ], desired_state: false, default: lazy { |r| r.docker?(r.node) && r.special_docker_files?(r.path) ? false : Chef::Config[:file_atomic_update] } + property :atomic_update, [ true, false ], desired_state: false, default: lazy { |r| r.docker? && r.special_docker_files?(r.path) ? false : Chef::Config[:file_atomic_update] } property :backup, [ Integer, false ], desired_state: false, default: 5 property :checksum, [ /^[a-zA-Z0-9]{64}$/, nil ] property :content, [ String, nil ], desired_state: false |