diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-01 21:54:43 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-01 21:54:43 -0800 |
commit | f706c6a4183c5d2807ead7ed1c26cf2b8cfef921 (patch) | |
tree | b7d02c5f9dca846107d93569485698e57149af89 /lib/chef | |
parent | 46d19a502fb8824fa3fccf4535fcfa226c4e9473 (diff) | |
download | chef-f706c6a4183c5d2807ead7ed1c26cf2b8cfef921.tar.gz |
support why-run by defaultlcg/default-whyrun-supported
this should fix several bugs in providers that look like they should
support whyrun but fail to declare it.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
37 files changed, 32 insertions, 149 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 40c31e4371..0ec441202c 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) -# Copyright:: Copyright 2008-2016, 2009-2016 Chef Software, Inc. +# Copyright:: Copyright 2008-2016, 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,7 +75,7 @@ class Chef end def whyrun_supported? - false + true end def node diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb index 9e91b12373..2d5f180738 100644 --- a/lib/chef/provider/apt_repository.rb +++ b/lib/chef/provider/apt_repository.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +35,6 @@ class Chef which("apt-get") end - def whyrun_supported? - true - end - def load_current_resource end diff --git a/lib/chef/provider/apt_update.rb b/lib/chef/provider/apt_update.rb index baa763df9d..135bd64035 100644 --- a/lib/chef/provider/apt_update.rb +++ b/lib/chef/provider/apt_update.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,10 +34,6 @@ class Chef APT_CONF_DIR = "/etc/apt/apt.conf.d" STAMP_DIR = "/var/lib/apt/periodic" - def whyrun_supported? - true - end - def load_current_resource end diff --git a/lib/chef/provider/breakpoint.rb b/lib/chef/provider/breakpoint.rb index 0902634a64..9f8b8a6467 100644 --- a/lib/chef/provider/breakpoint.rb +++ b/lib/chef/provider/breakpoint.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index f22367b461..a45e889bcc 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -42,10 +42,6 @@ class Chef end attr_accessor :cron_exists, :cron_empty - def whyrun_supported? - true - end - def load_current_resource crontab_lines = [] @current_resource = Chef::Resource::Cron.new(new_resource.name) diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb index 2cd6ad62c6..172705ac71 100644 --- a/lib/chef/provider/deploy.rb +++ b/lib/chef/provider/deploy.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,10 +46,6 @@ class Chef @configuration[:environment] = @configuration[:environment] && @configuration[:environment]["RAILS_ENV"] end - def whyrun_supported? - true - end - def load_current_resource @scm_provider.load_current_resource @release_path = new_resource.deploy_to + "/releases/#{release_slug}" diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb index 38ee1f241f..a176230bba 100644 --- a/lib/chef/provider/directory.rb +++ b/lib/chef/provider/directory.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,10 +29,6 @@ class Chef provides :directory - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Directory.new(new_resource.name) current_resource.path(new_resource.path) diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb index 0ad075484f..959227b408 100644 --- a/lib/chef/provider/dsc_resource.rb +++ b/lib/chef/provider/dsc_resource.rb @@ -1,7 +1,7 @@ # # Author:: Adam Edwards (<adamed@chef.io>) # -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,10 +45,6 @@ class Chef def load_current_resource end - def whyrun_supported? - true - end - def define_resource_requirements requirements.assert(:run) do |a| a.assertion { supports_dsc_invoke_resource? } diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index 66783ceb0f..654f202ed9 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -1,7 +1,7 @@ # # Author:: Adam Edwards (<adamed@chef.io>) # -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -58,10 +58,6 @@ class Chef end end - def whyrun_supported? - true - end - def define_resource_requirements requirements.assert(:run) do |a| err = [ diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb index 5e05fe4798..7777da183d 100644 --- a/lib/chef/provider/env.rb +++ b/lib/chef/provider/env.rb @@ -28,6 +28,10 @@ class Chef provides :env, os: "!windows" + def whyrun_supported? + false + end + def initialize(new_resource, run_context) super @key_exists = true diff --git a/lib/chef/provider/env/windows.rb b/lib/chef/provider/env/windows.rb index e25cab31d2..e813025c81 100644 --- a/lib/chef/provider/env/windows.rb +++ b/lib/chef/provider/env/windows.rb @@ -26,6 +26,10 @@ class Chef provides :env, os: "windows" + def whyrun_supported? + false + end + def create_env obj = env_obj(@new_resource.key_name) unless obj diff --git a/lib/chef/provider/erl_call.rb b/lib/chef/provider/erl_call.rb index 50571d5256..26ac19d03b 100644 --- a/lib/chef/provider/erl_call.rb +++ b/lib/chef/provider/erl_call.rb @@ -31,10 +31,6 @@ class Chef super(node, new_resource) end - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 81bfd25158..101d7c4c06 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -34,10 +34,6 @@ class Chef current_resource end - def whyrun_supported? - true - end - def define_resource_requirements if creates && creates_relative? && !cwd # FIXME? move this onto the resource? diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index ecde068751..9f8bfffd29 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -72,10 +72,6 @@ class Chef super end - def whyrun_supported? - true - end - def load_current_resource # true if there is a symlink and we need to manage what it points at @managing_symlink = file_class.symlink?(new_resource.path) && ( new_resource.manage_symlink_source || new_resource.manage_symlink_source.nil? ) diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 2907c20211..db83e0aea6 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,10 +30,6 @@ class Chef def_delegator :new_resource, :destination, :cwd - def whyrun_supported? - true - end - def load_current_resource @resolved_reference = nil @current_resource = Chef::Resource::Git.new(new_resource.name) diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb index 6751052ae4..82196c72f3 100644 --- a/lib/chef/provider/group.rb +++ b/lib/chef/provider/group.rb @@ -1,6 +1,6 @@ # # Author:: AJ Christensen (<aj@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,10 +29,6 @@ class Chef attr_accessor :group_exists attr_accessor :change_desc - def whyrun_supported? - true - end - def initialize(new_resource, run_context) super @group_exists = true diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb index eaca17a972..8370c2375c 100644 --- a/lib/chef/provider/http_request.rb +++ b/lib/chef/provider/http_request.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,10 +27,6 @@ class Chef attr_accessor :http - def whyrun_supported? - true - end - def load_current_resource @http = Chef::HTTP::Simple.new(new_resource.url) end diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 4f32baaadb..003cc3b0e0 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -53,10 +53,6 @@ class Chef @config_path = nil end - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Ifconfig.new(new_resource.name) diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index aed60b7c47..94f9120582 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,10 +42,6 @@ class Chef private :negative_complement - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Link.new(new_resource.name) current_resource.target_file(new_resource.target_file) diff --git a/lib/chef/provider/log.rb b/lib/chef/provider/log.rb index a0219db753..fbbc053b5b 100644 --- a/lib/chef/provider/log.rb +++ b/lib/chef/provider/log.rb @@ -1,6 +1,6 @@ # # Author:: Cary Penniman (<cary@rightscale.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,10 +27,6 @@ class Chef provides :log - def whyrun_supported? - true - end - # No concept of a 'current' resource for logs, this is a no-op # # === Return diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index 88da7b5eff..5c972462bc 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -29,10 +29,6 @@ class Chef raise Exception, "deprecated" end - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Mdadm.new(new_resource.name) current_resource.raid_device(new_resource.raid_device) diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb index 5168c93348..4d0d273ea9 100644 --- a/lib/chef/provider/mount.rb +++ b/lib/chef/provider/mount.rb @@ -1,7 +1,7 @@ # # Author:: Joshua Timberman (<joshua@chef.io>) # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software, Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,10 +28,6 @@ class Chef attr_accessor :unmount_retries - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/noop.rb b/lib/chef/provider/noop.rb index 207bf7dedb..ca8f7324f7 100644 --- a/lib/chef/provider/noop.rb +++ b/lib/chef/provider/noop.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/provider/ohai.rb b/lib/chef/provider/ohai.rb index c36655077b..0c2397cee5 100644 --- a/lib/chef/provider/ohai.rb +++ b/lib/chef/provider/ohai.rb @@ -25,10 +25,6 @@ class Chef provides :ohai - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb index 9ea68f4c9f..1172e25eed 100644 --- a/lib/chef/provider/osx_profile.rb +++ b/lib/chef/provider/osx_profile.rb @@ -29,10 +29,6 @@ class Chef provides :osx_profile, os: "darwin" provides :osx_config_profile, os: "darwin" - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::OsxProfile.new(new_resource.name) current_resource.profile_name(new_resource.profile_name) diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index 97aefbd559..36df048741 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -61,10 +61,6 @@ class Chef end end - def whyrun_supported? - true - end - def check_resource_semantics! # FIXME: this is not universally true and subclasses are needing to override this and no-ops it. It should be turned into # another "subclass_directive" and the apt and yum providers should declare that they need this behavior. diff --git a/lib/chef/provider/reboot.rb b/lib/chef/provider/reboot.rb index ff85f7a99a..32dc38f788 100644 --- a/lib/chef/provider/reboot.rb +++ b/lib/chef/provider/reboot.rb @@ -24,10 +24,6 @@ class Chef class Reboot < Chef::Provider provides :reboot - def whyrun_supported? - true - end - def load_current_resource @current_resource ||= Chef::Resource::Reboot.new(new_resource.name) current_resource.reason(new_resource.reason) diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb index 2443a3d184..f196154986 100644 --- a/lib/chef/provider/registry_key.rb +++ b/lib/chef/provider/registry_key.rb @@ -35,10 +35,6 @@ class Chef include Chef::Mixin::Checksum - def whyrun_supported? - true - end - def running_on_windows! unless Chef::Platform.windows? raise Chef::Exceptions::Win32NotWindows, "Attempt to manipulate the windows registry on a non-windows node" diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb index 5e20fdf11e..2e2a1266b4 100644 --- a/lib/chef/provider/route.rb +++ b/lib/chef/provider/route.rb @@ -84,10 +84,6 @@ class Chef end end - def whyrun_supported? - true - end - def load_current_resource self.is_running = false diff --git a/lib/chef/provider/ruby_block.rb b/lib/chef/provider/ruby_block.rb index c44b776661..878b7b52d3 100644 --- a/lib/chef/provider/ruby_block.rb +++ b/lib/chef/provider/ruby_block.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@chef.io>) # Author:: AJ Christensen (<aj@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software, Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,10 +22,6 @@ class Chef class RubyBlock < Chef::Provider provides :ruby_block - def whyrun_supported? - true - end - def load_current_resource true end diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb index 2f08697ed7..11d04eaca2 100644 --- a/lib/chef/provider/service.rb +++ b/lib/chef/provider/service.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@hjksolutions.com>) # Author:: Davide Cavalca (<dcavalca@fb.com>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +35,6 @@ class Chef @enabled = nil end - def whyrun_supported? - true - end - def load_current_resource supports[:status] = false if supports[:status].nil? supports[:reload] = false if supports[:reload].nil? diff --git a/lib/chef/provider/service/aix.rb b/lib/chef/provider/service/aix.rb index 201f9ff5f9..dd74caf6ae 100644 --- a/lib/chef/provider/service/aix.rb +++ b/lib/chef/provider/service/aix.rb @@ -1,6 +1,6 @@ # # Author:: kaustubh (<kaustubh@clogeny.com>) -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,10 +43,6 @@ class Chef @current_resource end - def whyrun_supported? - true - end - def start_service if @is_resource_group shell_out!("startsrc -g #{@new_resource.service_name}") diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index d75e85989f..84ced52071 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -41,10 +41,6 @@ class Chef @current_resource end - def whyrun_supported? - true - end - def shared_resource_requirements super requirements.assert(:all_actions) do |a| diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 9bfd9238cd..931e320695 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -2,7 +2,7 @@ # Author:: Nuo Yan <nuo@chef.io> # Author:: Bryan McLellan <btm@loftninjas.org> # Author:: Seth Chisamore <schisamo@chef.io> -# Copyright:: Copyright 2010-2016, Chef Software Inc. +# Copyright:: Copyright 2010-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,10 +49,6 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service SERVICE_RIGHT = "SeServiceLogonRight" - def whyrun_supported? - false - end - def load_current_resource @current_resource = Chef::Resource::WindowsService.new(@new_resource.name) @current_resource.service_name(@new_resource.service_name) diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index ee8ea7c495..d7e26f3968 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@kallistec.com>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,10 +35,6 @@ class Chef include Chef::Mixin::Command include ChefConfig::Mixin::FuzzyHostnameMatcher - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::Subversion.new(new_resource.name) diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index 43102e7dec..dcfee22c31 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -43,10 +43,6 @@ class Chef @group_name_resolved = false end - def whyrun_supported? - true - end - def load_current_resource @current_resource = Chef::Resource::User.new(new_resource.name) current_resource.username(new_resource.username) diff --git a/lib/chef/provider/yum_repository.rb b/lib/chef/provider/yum_repository.rb index be4d43f7ad..bcba8e676d 100644 --- a/lib/chef/provider/yum_repository.rb +++ b/lib/chef/provider/yum_repository.rb @@ -1,6 +1,6 @@ # # Author:: Thom May (<thom@chef.io>) -# Copyright:: Copyright (c) 2016 Chef Software, Inc. +# Copyright:: Copyright (c) 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,9 +34,8 @@ class Chef which "yum" end - def whyrun_supported?; true; end - - def load_current_resource; end + def load_current_resource + end action :create do declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do |