win_domain_user and win_domain_group: add created result boolean (#57901)

* win_domain_user and win_domain_group: add created result boolean

* Fix YML

* add docs

* brackets

* Update win_domain_group.py

* Update win_domain_user.py

* Update win_domain_user.ps1

* fix indent
This commit is contained in:
Shachaf92 2019-07-05 01:44:07 +03:00 committed by Jordan Borean
parent 07edcab051
commit a6b7d0d00b
6 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- "win_domain_user and win_domain_group: add created result boolean (https://github.com/ansible/ansible/issues/57547)"

View file

@ -28,6 +28,7 @@ $domain_server = Get-AnsibleParam -obj $params -name "domain_server" -type "str"
$result = @{ $result = @{
changed = $false changed = $false
created = $false
} }
if ($diff_mode) { if ($diff_mode) {
@ -289,6 +290,7 @@ if ($state -eq "absent") {
Fail-Json $result "failed to create group $($name): $($_.Exception.Message)" Fail-Json $result "failed to create group $($name): $($_.Exception.Message)"
} }
$result.changed = $true $result.changed = $true
$result.created = $true
} }
# set the protection value # set the protection value

View file

@ -234,4 +234,9 @@ sid:
returned: group exists returned: group exists
type: str type: str
sample: S-1-5-21-2171456218-3732823212-122182344-1189 sample: S-1-5-21-2171456218-3732823212-122182344-1189
created:
description: Whether a group was created
returned: always
type: bool
sample: true
''' '''

View file

@ -13,6 +13,7 @@ try {
$result = @{ $result = @{
changed = $false changed = $false
created = $false
password_updated = $false password_updated = $false
} }
@ -96,6 +97,7 @@ If ($state -eq 'present') {
New-ADUser -Name $username -WhatIf:$check_mode @extra_args New-ADUser -Name $username -WhatIf:$check_mode @extra_args
} }
$new_user = $true $new_user = $true
$result.created = $true
$result.changed = $true $result.changed = $true
If ($check_mode) { If ($check_mode) {
Exit-Json $result Exit-Json $result

View file

@ -362,4 +362,9 @@ user_cannot_change_password:
returned: always returned: always
type: str type: str
sample: false sample: false
created:
description: Whether a user was created
returned: always
type: bool
sample: true
''' '''

View file

@ -52,6 +52,7 @@
- name: assert create group with defaults - name: assert create group with defaults
assert: assert:
that: that:
- create_default is created
- create_default is changed - create_default is changed
- create_default.category == 'Security' - create_default.category == 'Security'
- create_default.description == None - create_default.description == None
@ -76,6 +77,7 @@
assert: assert:
that: that:
- create_default_again is not changed - create_default_again is not changed
- create_default_again is not created
- name: remove group check - name: remove group check
win_domain_group: win_domain_group:
@ -109,6 +111,7 @@
assert: assert:
that: that:
- remove_group is changed - remove_group is changed
- remove_group is not created
- remove_group_actual.rc == 1 - remove_group_actual.rc == 1
- name: remove group again - name: remove group again
@ -121,6 +124,7 @@
assert: assert:
that: that:
- remove_group_again is not changed - remove_group_again is not changed
- remove_group_again is not created
- name: create non default group check - name: create non default group check
win_domain_group: win_domain_group:
@ -148,6 +152,7 @@
assert: assert:
that: that:
- create_non_default_check is changed - create_non_default_check is changed
- create_non_default_check is created
- create_non_default_actual_check.rc == 1 - create_non_default_actual_check.rc == 1
- name: create non default group - name: create non default group
@ -175,6 +180,7 @@
assert: assert:
that: that:
- create_non_default is changed - create_non_default is changed
- create_non_default is created
- create_non_default.category == 'Distribution' - create_non_default.category == 'Distribution'
- create_non_default.description == 'Group Description' - create_non_default.description == 'Group Description'
- create_non_default.display_name == 'Group Display Name' - create_non_default.display_name == 'Group Display Name'
@ -208,6 +214,7 @@
assert: assert:
that: that:
- create_non_default_again is not changed - create_non_default_again is not changed
- create_non_default_again is not created
- name: try and move group with protection mode on - name: try and move group with protection mode on
win_domain_group: win_domain_group:
@ -241,6 +248,7 @@
assert: assert:
that: that:
- modify_existing_check is changed - modify_existing_check is changed
- modify_existing_check is not created
- modify_existing_actual_check.stdout == 'CN=' + test_win_domain_group_name + ',' + test_win_domain_group_ou_path + '\r\n' - modify_existing_actual_check.stdout == 'CN=' + test_win_domain_group_name + ',' + test_win_domain_group_ou_path + '\r\n'
- name: modify existing group - name: modify existing group
@ -267,6 +275,7 @@
assert: assert:
that: that:
- modify_existing is changed - modify_existing is changed
- modify_existing is not created
- modify_existing.category == 'Security' - modify_existing.category == 'Security'
- modify_existing.description == 'New Description' - modify_existing.description == 'New Description'
- modify_existing.display_name == 'New Display Name' - modify_existing.display_name == 'New Display Name'
@ -300,6 +309,7 @@
assert: assert:
that: that:
- modify_existing_again is not changed - modify_existing_again is not changed
- modify_existing_again is not created
- name: fail change managed_by to invalid user - name: fail change managed_by to invalid user
win_domain_group: win_domain_group:
@ -333,6 +343,7 @@
assert: assert:
that: that:
- delete_with_force is changed - delete_with_force is changed
- delete_with_force is not created
- delete_with_force_actual.rc == 1 - delete_with_force_actual.rc == 1
- name: ensure the test group is deleted after the test - name: ensure the test group is deleted after the test