Open ChrisNicoll-Pro opened 1 year ago
Can confirm this is still happening with Ansible 2.16.9
ansible [core 2.16.9]
config file = /home/ubuntu/an/ansible.cfg
configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
Collection Version
----------------- -------
community.windows 2.2.0
CONFIG_FILE() = /home/ubuntu/an/ansible.cfg
DEFAULT_GATHERING(/home/ubuntu/an/ansible.cfg) = smart
DEFAULT_HOST_LIST(/home/ubuntu/an/ansible.cfg) = ['/home/ubuntu/an/inventories']
Target OS:
Windows 2019 Datacenter Version 1809 (OS Build 17763.6054)
Controller:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
SUMMARY
When setting a
domain_password
secret in the Windows 10 credential store, the task always reports as changed. Looking through the source code it appears to be due to the module failing to read the current value of the secret from the credential store. As a result, it falls back to always setting the secret due to the current value being unknown and, therefore, impossible to compare against.ISSUE TYPE
COMPONENT NAME
win_credential
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Targeting Windows 10
STEPS TO REPRODUCE
Run the following multiple times and it always reports as changed.
EXPECTED RESULTS
I'd expect this module to be able to read the stored secrets so the module is idempotent when used. If it really isn't possible to read the stored secrets, I think it should at least log a warning message to notify users. The current implementation makes it impossible to know whether the stored credential was different or if it failed to read it.
ACTUAL RESULTS
The module always overwrites the secret due to
$existing_credential.Secret.Length -eq 0
(L683) always resolving to true.