summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-02 15:41:14 -0800
committerTim Smith <tsmith@chef.io>2018-03-02 15:41:14 -0800
commit2a098b7a4fc94d42050c6c0bc92cb08fb78a6817 (patch)
treea3a3b8f7f5cf0eff1644c4a16db72d496564e04e
parent709fc722eddca95f0b4c6b5eef6cd6bb37d794a7 (diff)
downloadchef-2a098b7a4fc94d42050c6c0bc92cb08fb78a6817.tar.gz
Add description and introduced fields
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/windows_feature.rb40
-rw-r--r--lib/chef/resource/windows_feature_dism.rb29
-rw-r--r--lib/chef/resource/windows_feature_powershell.rb38
3 files changed, 92 insertions, 15 deletions
diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb
index aadf0efb03..101140e940 100644
--- a/lib/chef/resource/windows_feature.rb
+++ b/lib/chef/resource/windows_feature.rb
@@ -21,22 +21,50 @@ class Chef
resource_name :windows_feature
provides :windows_feature
- property :feature_name, [Array, String], name_property: true
- property :source, String
- property :all, [true, false], default: false
- property :management_tools, [true, false], default: false
- property :install_method, Symbol, equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd]
- property :timeout, Integer, default: 600
+ description "Using the windows_feature resource to add, remove or delete Windows features and roles"
+ introduced "14.0"
+
+ property :feature_name, [Array, String],
+ description: "The name of the feature/role(s) to install. The same feature may have different"\
+ " names depending on the underlying resource being used (ie DHCPServer vs DHCP;"\
+ " DNS-Server-Full-Role vs DNS).",
+ name_property: true
+
+ property :source, String,
+ description: "Use a local repository for the feature install."
+
+ property :all, [true, false],
+ description: "Install all sub features.",
+ default: false
+
+ property :management_tools, [true, false],
+ description: "Install all applicable management tools of the roles, role services, or features (PowerShell only).",
+ default: false
+
+ property :install_method, Symbol,
+ description: "If DISM or PowerShell should be used for the installation. Note feature names differ"\
+ "between the two installation methods.",
+ equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd]
+
+ property :timeout, Integer,
+ description: "Specifies a timeout (in seconds) for feature install.",
+ default: 600
action :install do
+ description "Install a Windows role/feature"
+
run_default_subresource :install
end
action :remove do
+ description "Remove a Windows role/feature"
+
run_default_subresource :remove
end
action :delete do
+ description "Remove a Windows role/feature from the image"
+
run_default_subresource :delete
end
diff --git a/lib/chef/resource/windows_feature_dism.rb b/lib/chef/resource/windows_feature_dism.rb
index aece7a78f3..f4abb7af6b 100644
--- a/lib/chef/resource/windows_feature_dism.rb
+++ b/lib/chef/resource/windows_feature_dism.rb
@@ -22,12 +22,29 @@ class Chef
resource_name :windows_feature_dism
provides :windows_feature_dism
- property :feature_name, [Array, String], coerce: proc { |x| Array(x) }, name_property: true
- property :source, String
- property :all, [true, false], default: false
- property :timeout, Integer, default: 600
+ description "Using the windows_feature_dism resource to add, remove or "\
+ "delete Windows features and roles using DISM"
+ introduced "14.0"
+
+ property :feature_name, [Array, String],
+ description: "The name of the feature/role(s) to install if it differs from the resource name.",
+ coerce: proc { |x| Array(x) },
+ name_property: true
+
+ property :source, String,
+ description: "Use a local repository for the feature install."
+
+ property :all, [true, false],
+ description: "Install all sub features. This is the equivalent of specifying the /All switch to dism.exe",
+ default: false
+
+ property :timeout, Integer,
+ description: "Specifies a timeout (in seconds) for feature install.",
+ default: 600
action :install do
+ description "Install a Windows role/feature using DISM"
+
reload_cached_dism_data unless node["dism_features_cache"]
fail_if_unavailable # fail if the features don't exist
fail_if_removed # fail if the features are in removed state
@@ -46,6 +63,8 @@ class Chef
end
action :remove do
+ description "Remove a Windows role/feature using DISM"
+
reload_cached_dism_data unless node["dism_features_cache"]
Chef::Log.debug("Windows features needing removal: #{features_to_remove.empty? ? 'none' : features_to_remove.join(',')}")
@@ -61,6 +80,8 @@ class Chef
end
action :delete do
+ description "Remove a Windows role/feature from the image using DISM"
+
fail_if_delete_unsupported
reload_cached_dism_data unless node["dism_features_cache"]
diff --git a/lib/chef/resource/windows_feature_powershell.rb b/lib/chef/resource/windows_feature_powershell.rb
index e7c785ab3c..60a22578fd 100644
--- a/lib/chef/resource/windows_feature_powershell.rb
+++ b/lib/chef/resource/windows_feature_powershell.rb
@@ -22,15 +22,39 @@ class Chef
resource_name :windows_feature_powershell
provides :windows_feature_powershell
- property :feature_name, [Array, String], coerce: proc { |x| Array(x) }, name_property: true
- property :source, String
- property :all, [true, false], default: false
- property :timeout, Integer, default: 600
- property :management_tools, [true, false], default: false
+ description "Use the windows_feature_powershell resource to add, remove or "\
+ "delete Windows features and roles using PowerShell. This resource"\
+ "offers significant speed benefits over the windows_feature_dism resource,"\
+ "but requires installing the Remote Server Administration Tools on"\
+ "non-server releases of Windows"
+ introduced "14.0"
+
+ property :feature_name, [Array, String],
+ description: "The name of the feature/role(s) to install if it differs from the resource name.",
+ coerce: proc { |x| Array(x) },
+ name_property: true
+
+ property :source, String,
+ description: "Use a local repository for the feature install."
+
+ property :all, [true, false],
+ description: "Install all sub features. This is equivalent to using the"\
+ " -InstallAllSubFeatures switch with Add-WindowsFeature.",
+ default: false
+
+ property :timeout, Integer,
+ description: "Specifies a timeout (in seconds) for feature install.",
+ default: 600
+
+ property :management_tools, [true, false],
+ description: "",
+ default: false
include Chef::Mixin::PowershellOut
action :install do
+ description "Install a Windows role/feature using PowerShell"
+
Chef::Log.warn("Requested feature #{new_resource.feature_name.join(',')} is not available on this system.") unless available?
unless !available? || installed?
converge_by("install Windows feature#{'s' if new_resource.feature_name.count > 1} #{new_resource.feature_name.join(',')}") do
@@ -48,6 +72,8 @@ class Chef
end
action :remove do
+ description "Remove a Windows role/feature using PowerShell"
+
if installed?
converge_by("remove Windows feature#{'s' if new_resource.feature_name.count > 1} #{new_resource.feature_name.join(',')}") do
cmd = powershell_out!("#{remove_feature_cmdlet} #{new_resource.feature_name.join(',')}", timeout: new_resource.timeout)
@@ -57,6 +83,8 @@ class Chef
end
action :delete do
+ description "Remove a Windows role/feature from the image using Powershell"
+
if available?
converge_by("delete Windows feature#{'s' if new_resource.feature_name.count > 1} #{new_resource.feature_name.join(',')} from the image") do
cmd = powershell_out!("Uninstall-WindowsFeature #{new_resource.feature_name.join(',')} -Remove", timeout: new_resource.timeout)