summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_domain_computer
diff options
context:
space:
mode:
authorJordan Borean <jborean93@gmail.com>2019-12-04 07:13:59 +1000
committerMatt Davis <nitzmahone@users.noreply.github.com>2019-12-03 13:13:59 -0800
commit18af2d257fec6878cd2de59f3a9f23e54a80c6fd (patch)
treeb92f9782881443b4aa546a2a8b4c72d7b728268e /test/integration/targets/win_domain_computer
parentf3c58f554ca2c430a819e47ff31eec2089fc9f83 (diff)
downloadansible-18af2d257fec6878cd2de59f3a9f23e54a80c6fd.tar.gz
win_domain_computer module: Fix idempotence when name != sam_account_name (#56967) (#64816)
* win_domain_computer module: Minor documentation error * Fix idempotence when name != samaccountname * Added changelog * Added unsupported alias for CI check (cherry picked from commit 04b8f75ffab5212822329af19f31b70b847f6aa3)
Diffstat (limited to 'test/integration/targets/win_domain_computer')
-rw-r--r--test/integration/targets/win_domain_computer/aliases1
-rw-r--r--test/integration/targets/win_domain_computer/tasks/main.yml71
2 files changed, 72 insertions, 0 deletions
diff --git a/test/integration/targets/win_domain_computer/aliases b/test/integration/targets/win_domain_computer/aliases
new file mode 100644
index 0000000000..ad7ccf7ada
--- /dev/null
+++ b/test/integration/targets/win_domain_computer/aliases
@@ -0,0 +1 @@
+unsupported
diff --git a/test/integration/targets/win_domain_computer/tasks/main.yml b/test/integration/targets/win_domain_computer/tasks/main.yml
new file mode 100644
index 0000000000..98f18acac2
--- /dev/null
+++ b/test/integration/targets/win_domain_computer/tasks/main.yml
@@ -0,0 +1,71 @@
+# this won't run in Ansible's integration tests until we get a domain set up
+# these are here if someone wants to run the module tests locally on their own
+# domain.
+# Requirements:
+# LDAP Base path set in defaults/main.yml like DC=ansible,DC=local
+# Custom OU path set in defaults/main.yml like OU=ou1,DC=ansible,DC=local
+---
+- name: run win_domain_users test
+ hosts: win_domain_computer_testing_host
+ vars:
+ test_win_domain_computer_ldap_base: "{{ test_ad_ou }}"
+ test_win_domain_computer_ou_path: "{{ test_ad_group_ou }}"
+ test_win_domain_computer_name: "test_computer.{{ test_domain_name }}"
+ tasks:
+
+ - name: ensure the computer is deleted before the test
+ win_domain_computer:
+ name: '{{ test_win_domain_computer_name }}'
+ state: absent
+
+ # --------------------------------------------------------------------------
+
+ - name: Test computer with long name and distinct sam_account_name
+ vars:
+ test_win_domain_computer_long_name: '{{ test_win_domain_computer_name }}_with_long_name'
+ test_win_domain_computer_sam_account_name: '{{ test_win_domain_computer_name }}$'
+ block:
+
+ # ----------------------------------------------------------------------
+ - name: create computer with long name and distinct sam_account_name
+ win_domain_computer:
+ name: '{{ test_win_domain_computer_long_name }}'
+ sam_account_name: '{{ test_win_domain_computer_sam_account_name }}'
+ enabled: yes
+ state: present
+ register: create_distinct_sam_account_name
+ check_mode: yes
+
+ - name: get actual computer with long name and distinct sam_account_name
+ win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADComputer -Identity '{{ test_win_domain_computer_sam_account_name }}'"
+ register: create_distinct_sam_account_name_check
+ ignore_errors: True
+
+ - name: assert create computer with long name and distinct sam_account_name
+ assert:
+ that:
+ - create_distinct_sam_account_name is changed
+ - create_distinct_sam_account_name_check.rc == 1
+
+ - name: (Idempotence) create computer with long name and distinct sam_account_name
+ win_domain_computer:
+ name: '{{ test_win_domain_computer_long_name }}'
+ sam_account_name: '{{ test_win_domain_computer_sam_account_name }}'
+ enabled: yes
+ state: present
+ register: create_distinct_sam_account_name_idempotence
+ check_mode: yes
+
+ - name: (Idempotence) assert create computer with long name and distinct sam_account_name
+ assert:
+ that:
+ - create_distinct_sam_account_name_idempotence is not changed
+
+ - name: ensure the test group is deleted after the test
+ win_domain_computer:
+ name: '{{ test_win_domain_computer_long_name }}'
+ sam_account_name: '{{ test_win_domain_computer_sam_account_name }}'
+ state: absent
+ ignore_protection: True
+
+ # ----------------------------------------------------------------------