diff --git a/changelogs/fragments/group-domainlocal-scopeinfo.yml b/changelogs/fragments/group-domainlocal-scopeinfo.yml new file mode 100644 index 0000000..6a4aa08 --- /dev/null +++ b/changelogs/fragments/group-domainlocal-scopeinfo.yml @@ -0,0 +1,3 @@ +bugfixes: +- >- + group - Fix idempotency check when ``scope: domainlocal`` is set - https://github.com/ansible-collections/microsoft.ad/issues/31 diff --git a/plugins/module_utils/_ADObject.psm1 b/plugins/module_utils/_ADObject.psm1 index 577f6c7..4a7ccf8 100644 --- a/plugins/module_utils/_ADObject.psm1 +++ b/plugins/module_utils/_ADObject.psm1 @@ -425,7 +425,7 @@ Function Compare-AnsibleADIdempotentList { ) # It's easier to compare with strings. - $existingString = [string[]]@(if ($Existing) { $Existing | ForEach-Object ToString }) + $existingString = [string[]]@(if ($null -ne $Existing) { $Existing | ForEach-Object ToString }) $comparer = if ($CaseInsensitive) { [System.StringComparer]::OrdinalIgnoreCase } diff --git a/tests/integration/targets/group/tasks/tests.yml b/tests/integration/targets/group/tasks/tests.yml index 9b026d1..bdb1b95 100644 --- a/tests/integration/targets/group/tasks/tests.yml +++ b/tests/integration/targets/group/tasks/tests.yml @@ -421,6 +421,30 @@ - group_custom_actual.objects[0].sAMAccountName == "GroupSAM" - group_custom_actual.objects[0].wWWHomePage == "www.ansible.com" + - name: create group with custom options - idempotent + group: + name: MyGroup + state: present + path: '{{ ou_info.distinguished_name }}' + display_name: My Display Name + description: My Description + scope: domainlocal + category: distribution + homepage: www.ansible.com + managed_by: CN=Domain Admins,CN=Users,{{ setup_domain_info.output[0].defaultNamingContext }} + members: + add: + - my_user_1 + - '{{ test_users.results[1].object_guid }}' + - '{{ test_users.results[2].sid }}' + sam_account_name: GroupSAM + register: group_custom_again + + - name: assert create group with custom options - idempotent + assert: + that: + - group_custom_again is not changed + - name: edit group group: name: MyGroup