summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordheerajd-msys <dheeraj.dubey@msystechnologies.com>2018-06-11 17:40:50 +0530
committerdheerajd-msys <dheeraj.dubey@msystechnologies.com>2018-06-11 17:40:50 +0530
commit2cbcad439c29cde34762fffcf6990c9825066138 (patch)
treebd7720d435d9d98920377896546d3b6cb7b395bf
parent9138b6da9f344f77c574e939de387590ff284eba (diff)
downloadchef-2cbcad439c29cde34762fffcf6990c9825066138.tar.gz
[MSYS-830] Fix package sensitive error
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r--lib/chef/provider/package/windows/exe.rb36
-rw-r--r--lib/chef/resource/windows_package.rb5
2 files changed, 29 insertions, 12 deletions
diff --git a/lib/chef/provider/package/windows/exe.rb b/lib/chef/provider/package/windows/exe.rb
index 6499d0cfeb..a32c207596 100644
--- a/lib/chef/provider/package/windows/exe.rb
+++ b/lib/chef/provider/package/windows/exe.rb
@@ -55,17 +55,27 @@ class Chef
def install_package
logger.trace("#{new_resource} installing #{new_resource.installer_type} package '#{new_resource.source}'")
- shell_out!(
- [
- "start",
- "\"\"",
- "/wait",
- "\"#{new_resource.source}\"",
- unattended_flags,
- expand_options(new_resource.options),
- "& exit %%%%ERRORLEVEL%%%%",
- ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns
- )
+ begin
+ shell_out!(
+ [
+ "start",
+ "\"\"",
+ "/wait",
+ "\"#{new_resource.source}\"",
+ unattended_flags,
+ expand_options(new_resource.options),
+ "& exit %%%%ERRORLEVEL%%%%",
+ ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns
+ )
+ rescue Mixlib::ShellOut::ShellCommandFailed
+ if sensitive?
+ ex = Mixlib::ShellOut::ShellCommandFailed.new("Command execution failed. STDOUT/STDERR suppressed for sensitive resource")
+ raise ex
+ else
+ raise
+ end
+ end
+ logger.info("#{new_resource} ran successfully")
end
def remove_package
@@ -79,6 +89,10 @@ class Chef
private
+ def sensitive?
+ !!new_resource.sensitive
+ end
+
def uninstall_command(uninstall_string)
uninstall_string = "\"#{uninstall_string}\"" if ::File.exist?(uninstall_string)
uninstall_string = [
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index 49496aed9a..fb0f2c26ae 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -42,7 +42,10 @@ class Chef
end
# windows can't take array options yet
- property :options, String
+ property :options, String, sensitive: true
+
+ # lazy used to set default value of sensitive to true if options is set
+ property :sensitive, [ TrueClass, FalseClass ], default: lazy { |r| r.options ? true : false }
# Unique to this resource
property :installer_type, Symbol