Description
SUMMARY
I have a behavior that has existed since 2.5 (when the "update_only: yes" attribute was added to the yum module) and still exists with 2.8:
When using the attribute "update_only: yes" with the yum module when updating specific packages on a system to their latest version, when it comes across a package that is not currently installed, the output incorrectly reports it as "changed" when it check mode (using the "--check" option). When not in check mode and doing it for real, it correctly reports the same uninstalled package step with "ok:" (no change). It's only in check mode that it doesn't report correctly what it would do for real, so you get two different results for check mode vs. non-check mode, and can't use check mode to properly check whether systems have been updated. Is this a bug?
ISSUE TYPE
- Bug Report
COMPONENT NAME
yum module
ANSIBLE VERSION
# ansible --version
ansible 2.8.3
config file = /etc/ansible/ansible.cfg
configured module search path = ['/etc/ansible/library']
ansible python module location = /usr/local/conda-py3.7-x86_64/envs/ansible-py3/lib/python3.7/site-packages/ansible
executable location = /usr/local/conda-py3.7-x86_64/envs/ansible-py3/bin/ansible
python version = 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0]
CONFIGURATION
OS / ENVIRONMENT
Target OS: RHEL7, RHEL6
STEPS TO REPRODUCE
--Run a playbook with the "yum" module to update specific packages to their latest version (state: latest), and which contains the "update_only: yes" directive so as to only update the package if it is already installed.
--If you run the playbook WITH the "--check" option, it incorrectly shows packages that are not yet installed as "changed", indicating that it would make a change to the system.
--If you run the package WITHOUT the "--check" option, it correctly shows packages that are not yet installed as "ok", and makes no changes.
EXPECTED RESULTS
I should receive the same results both with and without using the "--check" option.
ACTUAL RESULTS