summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel-Sanchez-Fabregas <33929811+Daniel-Sanchez-Fabregas@users.noreply.github.com>2018-09-04 23:29:40 +0200
committerMatt Clay <matt@mystile.com>2018-09-04 14:29:40 -0700
commit67e880dd8206b15a6091421bc4c73e3285e5406e (patch)
treeb40614beef0b1568ff712665086f11c591289e6e
parentf7f6d47c7e3f418dc4b39912eddc96c9d2e5679a (diff)
downloadansible-67e880dd8206b15a6091421bc4c73e3285e5406e.tar.gz
Backport/2.6/44500 Module win_domain_computer fix delete computer with child (#44707)
* Module win_domain_computer fix delete computer with child (cherry picked from commit bbecdbc042c6ab6cd158abd8302dca308cf39153) * add changelog fragment (cherry picked from commit b6af40a1cc7a0796cdbe96ebfc78b2ad501c0fdb)
-rw-r--r--changelogs/fragments/44500-win_domain_computer.yaml2
-rw-r--r--lib/ansible/modules/windows/win_domain_computer.ps15
2 files changed, 5 insertions, 2 deletions
diff --git a/changelogs/fragments/44500-win_domain_computer.yaml b/changelogs/fragments/44500-win_domain_computer.yaml
new file mode 100644
index 0000000000..4fbe62111b
--- /dev/null
+++ b/changelogs/fragments/44500-win_domain_computer.yaml
@@ -0,0 +1,2 @@
+bugfixes:
+- win_domain_computer - fixed deletion of computer active directory object that have dependent objects (https://github.com/ansible/ansible/pull/44500)
diff --git a/lib/ansible/modules/windows/win_domain_computer.ps1 b/lib/ansible/modules/windows/win_domain_computer.ps1
index d7413bfc45..1cc9f1a25f 100644
--- a/lib/ansible/modules/windows/win_domain_computer.ps1
+++ b/lib/ansible/modules/windows/win_domain_computer.ps1
@@ -129,8 +129,9 @@ Function Add-ConstructedState($desired_state) {
# ------------------------------------------------------------------------------
Function Remove-ConstructedState($initial_state) {
Try {
- Remove-ADComputer `
- -Identity $initial_state.name `
+ Get-ADComputer $initial_state.name `
+ | Remove-ADObject `
+ -Recursive `
-Confirm:$False `
-WhatIf:$check_mode
} Catch {