summaryrefslogtreecommitdiff
path: root/lib/chef/resource/execute.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource/execute.rb')
-rw-r--r--lib/chef/resource/execute.rb103
1 files changed, 13 insertions, 90 deletions
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index de927ec06e..b654969cb0 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -26,10 +26,9 @@ class Chef
# nature) not idempotent, as they are typically unique to the environment in which they are run. Use not_if and only_if
# to guard this resource for idempotence.
class Execute < Chef::Resource
+ resource_name :execute
- identity_attr :command
-
- # The ResourceGuardInterpreter wraps a resource's guards in another resource. That inner resource
+ # The ResourceGuardInterpreter wraps a resource's guards in another resource. That inner resource
# needs to behave differently during (for example) why_run mode, so we flag it here. For why_run mode
# we still want to execute the guard resource even if we are not executing the wrapping resource.
# Only execute resources (and subclasses) can be guard interpreters.
@@ -39,104 +38,28 @@ class Chef
def initialize(name, run_context = nil)
super
- @command = name
@backup = 5
- @creates = nil
- @cwd = nil
- @environment = nil
- @group = nil
- @returns = 0
- @timeout = nil
- @user = nil
- @umask = nil
@default_guard_interpreter = :execute
@is_guard_interpreter = false
- @live_stream = false
- end
-
- def umask(arg = nil)
- set_or_return(
- :umask,
- arg,
- :kind_of => [ String, Integer ]
- )
- end
-
- def command(arg = nil)
- set_or_return(
- :command,
- arg,
- :kind_of => [ String, Array ]
- )
- end
-
- def creates(arg = nil)
- set_or_return(
- :creates,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def cwd(arg = nil)
- set_or_return(
- :cwd,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def environment(arg = nil)
- set_or_return(
- :environment,
- arg,
- :kind_of => [ Hash ]
- )
- end
-
- alias :env :environment
-
- def group(arg = nil)
- set_or_return(
- :group,
- arg,
- :kind_of => [ String, Integer ]
- )
- end
-
- def live_stream(arg = nil)
- set_or_return(
- :live_stream,
- arg,
- :kind_of => [ TrueClass, FalseClass ])
- end
-
- def returns(arg = nil)
- set_or_return(
- :returns,
- arg,
- :kind_of => [ Integer, Array ]
- )
- end
-
- def timeout(arg = nil)
- set_or_return(
- :timeout,
- arg,
- :kind_of => [ Integer, Float ]
- )
end
+ property :umask, [ String, Integer ]
+ property :command, [ String, Array ], name_property: true, identity: true
+ property :creates, String
+ property :cwd, String
+ property :environment, Hash
+ property :group, [ String, Integer ]
+ property :live_stream, [ TrueClass, FalseClass ], default: false
+ property :returns, [ Integer, Array ], default: 0
+ property :timeout, [ Integer, Float ]
property :user, [ String, Integer ]
-
property :domain, String
-
property :password, String, sensitive: true
-
property :sensitive, [ TrueClass, FalseClass ], default: false, coerce: proc { |x| password ? true : x }
-
property :elevated, [ TrueClass, FalseClass ], default: false
+ alias :env :environment
+
def self.set_guard_inherited_attributes(*inherited_attributes)
@class_inherited_attributes = inherited_attributes
end