ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.08k stars 3.42k forks source link

Inventory and Host modules are not idempotent in --check mode #14922

Open kk-at-redhat opened 8 months ago

kk-at-redhat commented 8 months ago

Please confirm the following

Bug Summary

Inventory and Host modules will report "ok" in real mode but "changed" in --check mode

AWX version

23.2.0

Select the relevant components

Installation method

docker development environment

Modifications

no

Ansible version

2.14.2

Operating system

Red Hat Enterprise Linux release 9.1 (Plow)

Web browser

Chrome

Steps to reproduce

test_bugs.yml

    - ansible.controller.inventory:
        name: 'Dynamic A'
        organization: 'A'

    - ansible.controller.host:
        name: 'Host A'
        inventory: 'Dynamic A'

ansible-playbook test_bugs.yml

ansible-playbook test_bugs.yml --check

Expected results

ok: [localhost] ...
ok: [localhost] ...

ok: [localhost] ...
ok: [localhost] ...

Actual results

ok: [localhost] ...
ok: [localhost] ...

changed: [localhost]
changed: [localhost]

Additional information

No response

thedoubl3j commented 8 months ago

after looking back at the previous issue, this might be how check mode is interpreting present since it is set as default. Check mode might be a fresh environment every time so with the default state as present on these modules, check mode is reporting back that yes I would make the change. I am not sure if check mode necessarily should be idempotent in this sense.

kk-at-redhat commented 8 months ago

I'm sorry, I can't agree with that. If all provided fields are the same in the existing object, Ansible should be reporting "OK" in both real and check mode. Just like all the other modules in this collection do.

thedoubl3j commented 8 months ago

Some modules are wrong and we should absolutely change that so the behavior is consistent across the collection but check mode at its definition is not idempotent. We are not actually changing anything so therefore, the change will "always" occur in a check run because it has no concept of the previous check run.

I will amend my previous statement that the 2 issues you opened are separate completely #14923 and I will answer separately there.

I would open a new issue for the entire collection and close this one since this is more specific to these modules when in reality, the whole collection has issues around our inconsistent support of check mode.

kk-at-redhat commented 8 months ago

Actually, most of the modules I worked with so far are fine.

These work as expected: template, project, organization, group, credential type, credential (without password), inventory source, user (without password), instance group, settings.

I'll try to contribute if I have some free cycles.