mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
* Update core modules to fix strict mode errors. * Also fix creates parameter issue in win_msi as described in https://github.com/ansible/ansible-modules-core/issues/129, slightly different fix from https://github.com/ansible/ansible-modules-core/pull/1482 * Fix setup.ps1 module issue described in https://github.com/ansible/ansible-modules-core/issues/1927
This commit is contained in:
parent
6f36629d13
commit
9ed0a5a920
7 changed files with 65 additions and 125 deletions
|
@ -24,35 +24,31 @@ $params = Parse-Args $args;
|
|||
$result = New-Object PSObject;
|
||||
Set-Attr $result "changed" $false;
|
||||
|
||||
If (-not $params.name.GetType) {
|
||||
Fail-Json $result "missing required arguments: name"
|
||||
$name = Get-Attr $params "name" -failifempty $true
|
||||
|
||||
$state = Get-Attr $params "state" "present"
|
||||
$state = $state.ToString().ToLower()
|
||||
If (($state -ne "present") -and ($state -ne "absent")) {
|
||||
Fail-Json $result "state is '$state'; must be 'present' or 'absent'"
|
||||
}
|
||||
|
||||
If ($params.state) {
|
||||
$state = $params.state.ToString().ToLower()
|
||||
If (($state -ne "present") -and ($state -ne "absent")) {
|
||||
Fail-Json $result "state is '$state'; must be 'present' or 'absent'"
|
||||
}
|
||||
}
|
||||
Elseif (-not $params.state) {
|
||||
$state = "present"
|
||||
}
|
||||
$description = Get-Attr $params "description" $null
|
||||
|
||||
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
|
||||
$group = $adsi.Children | Where-Object {$_.SchemaClassName -eq 'group' -and $_.Name -eq $params.name }
|
||||
$group = $adsi.Children | Where-Object {$_.SchemaClassName -eq 'group' -and $_.Name -eq $name }
|
||||
|
||||
try {
|
||||
If ($state -eq "present") {
|
||||
If (-not $group) {
|
||||
$group = $adsi.Create("Group", $params.name)
|
||||
$group = $adsi.Create("Group", $name)
|
||||
$group.SetInfo()
|
||||
|
||||
Set-Attr $result "changed" $true
|
||||
}
|
||||
|
||||
If ($params.description.GetType) {
|
||||
IF (-not $group.description -or $group.description -ne $params.description) {
|
||||
$group.description = $params.description
|
||||
If ($null -ne $description) {
|
||||
IF (-not $group.description -or $group.description -ne $description) {
|
||||
$group.description = $description
|
||||
$group.SetInfo()
|
||||
Set-Attr $result "changed" $true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue