community.windows
community.windows copied to clipboard
win_domain_computer: Not able to check the OU objects before moving them
SUMMARY
win_domain_computer module is not validating the objects before moving them, instead its directly moving them from source to destination OU.
ISSUE TYPE
- Bug Report
COMPONENT NAME
- win_domain_computer
ANSIBLE VERSION
$ pip3 show ansible
Name: ansible
Version: 4.5.0
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/local/lib/python3.8/dist-packages
Requires: ansible-core
Required-by:
$ pip3 show ansible-core
Name: ansible-core
Version: 2.11.4
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/local/lib/python3.8/dist-packages
Requires: packaging, resolvelib, PyYAML, jinja2, cryptography
Required-by: ansible
COLLECTION VERSION
$ ansible-galaxy collection list community.windows
# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection Version
----------------- -------
community.windows 1.6.0
CONFIGURATION
OS / ENVIRONMENT
- Ubuntu 20.04 LTS
- Oracle Enterprise Linux 7.9
STEPS TO REPRODUCE
a. Make an ansible playbook with the following task to move one AD object from Servers to Workstation OU:
- name: Moving the WebApp vms from 'Servers' to 'Workstation' OU
win_domain_computer:
dns_hostname: "{{ item.name|upper }}"
name: "{{ item.name|upper }}"
ou: "ou=Workstation,ou=LocalAdmin,dc=example,dc=com"
state: present
loop: "{{ Servers}}"
when: Servers is defined
register: result
EXPECTED RESULTS
- If the objects available under Workstation OU, it should not do anything and just show 'ok'.
ACTUAL RESULTS
-
Even if the objects are already available in the target OU, its showing as 'changed' instead of 'ok'.
-
Debug is also showing that 'Changed: true'
@jborean93 could you please take a look at this ?
@Udayendu this is a community module and I didn't write the original implementation so my knowledge and understanding of how it works is very limited. I'll review PRs as best as I can but that's the the most I can do here.
@Udayendu this is a community module and I didn't write the original implementation so my knowledge and understanding of how it works is very limited. I'll review PRs as best as I can but that's the the most I can do here.
Sure. That will help.
I use this module and have not seen this behavior. My guess is that something about the way you're specifying the target OU makes it look different than the value returned when the module retrieves the info to compare it. @Udayendu are you possibly able to share the real OU name(s) in question? Do they contain (literal) comma ,
characters? I haven't looked at the code in a while but in my experience most code that uses Distinguished Name format does not properly deal with commas and escaping, so it's just a wild guess.
The win_domain_computer
module has been deprecated by https://github.com/ansible-collections/community.windows/pull/516 in favour of microsoft.ad.computer. See the migration guide for more info on how to change your code to use the newer module.
See https://github.com/ansible-collections/community.windows/issues/323#issuecomment-1566511341 for more info.