I have the following role in my Ansible playbook to determine the installed version of Packer and conditionally install it if it doesn't match the version of a local variable:
---
# detect packer version
- name: determine packer version
shell: /usr/local/bin/packer -v || true
register: packer_installed_version
- name: install packer cli tools
unarchive:
src: https://releases.hashicorp.com/packer/{{ packer_version }}/packer_{{ packer_version }}_linux_amd64.zip
dest: /usr/local/bin
copy: no
when: packer_installed_version.stdout != packer_version
The problem/annoyance is that Ansible marks this step as having "changed":
I'd like gather this fact without marking something as changed so I can know reliably at the end of my playbook execution if anything has, in fact, changed.
Is there a better way to go about what I'm doing above?
From the Ansible docs:
In your case you would want: