Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 of 11 tasks
kk-at-redhat opened this issue Feb 26, 2024 · 4 comments
Open
5 of 11 tasks

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

kk-at-redhat opened this issue Feb 26, 2024 · 4 comments
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug

Comments

@kk-at-redhat
Copy link

kk-at-redhat commented Feb 26, 2024

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to security@ansible.com instead.)

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

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

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

@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug community labels Feb 26, 2024
@thedoubl3j
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug
Projects
None yet
Development

No branches or pull requests

2 participants