diff options
author | Derek Groh <derekgroh@gmail.com> | 2018-08-29 15:53:08 -0500 |
---|---|---|
committer | Derek Groh <derekgroh@gmail.com> | 2018-08-29 15:53:16 -0500 |
commit | 1b6dc7655a4ba5930157eb0b5e5984e1ffdfb3bd (patch) | |
tree | d137a0574109fa34837ccdf437ba026126bca099 | |
parent | 84582e66edefb3cd2105928ea7e2428e0b13f5b4 (diff) | |
download | chef-1b6dc7655a4ba5930157eb0b5e5984e1ffdfb3bd.tar.gz |
Remove username and password as required
Signed-off-by: Derek Groh <derekgroh@github.io>
-rw-r--r-- | lib/chef/resource/windows_workgroup.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/chef/resource/windows_workgroup.rb b/lib/chef/resource/windows_workgroup.rb index e10a780cc5..dc9cfad087 100644 --- a/lib/chef/resource/windows_workgroup.rb +++ b/lib/chef/resource/windows_workgroup.rb @@ -27,7 +27,7 @@ class Chef include Chef::Mixin::PowershellOut description "Use the windows_workgroup resource to join change the workgroup of a machine." - introduced "14.0" + introduced "14.4" property :workgroup_name, String, description: "The name of the workgroup for the computer.", @@ -36,12 +36,10 @@ class Chef name_property: true property :user, String, - description: "The local user to use to change the workgroup.", - required: true + description: "The local administrator user to use to change the workgroup.", property :password, String, - description: "The password for the local user.", - required: true + description: "The password for the local administrator user.", property :reboot, Symbol, equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now], @@ -57,9 +55,10 @@ class Chef description "Update the workgroup." unless workgroup_member? - cmd = "$pswd = ConvertTo-SecureString \'#{new_resource.password}\' -AsPlainText -Force;" - cmd << "$credential = New-Object System.Management.Automation.PSCredential (\"#{new_resource.user}\",$pswd);" - cmd << "Add-Computer -WorkgroupName #{new_resource.workgroup_name} -Credential $credential" if new_resource.workgroup_name + cmd = "$pswd = ConvertTo-SecureString \'#{new_resource.password}\' -AsPlainText -Force;" if new_resource.password + cmd << "$credential = New-Object System.Management.Automation.PSCredential (\"#{new_resource.user}\",$pswd);" if new_resource.password + cmd << "Add-Computer -WorkgroupName #{new_resource.workgroup_name}" + cmd << " -Credential $credential" if new_resource.password cmd << " -Force" workgroup_member? converge_by("join workstation workgroup #{new_resource.workgroup_name}") do |