On Wednesday, June 4, 2014 7:28:47 AM UTC-7, Adam Morris wrote:
>
> In a similar situation I simply added a play to the role that stores a
> version number as a local fact. Then on subsequent runs I can check that
> local fact. The only proviso for that is that it is possible for someone to
> change the fact so don't rely on it for anything truly important.
Here's how I set the fact...
# Create the local facts directory if it doesn't exist
- name: ensure that the local facts directory exists
file: state=directory path="/etc/ansible/facts.d" mode=0755
# Set a local fact so that we don't do this again
- name: update the widget facts file so that this is not run next time.
ini_file: dest=/etc/ansible/facts.d/widgets.fact section=installed
option=version value={{ widgets_latest_version }} mode=0644
and in my case I add the following to all of the actual widget installation
tasks so that I don't reinstall (not quite your scenario)
when: "widgets_installed_version != widgets_latest_version"
and in that role I have a defaults/main.yml which sets these...
widgets_installed_version: "{{ ansible_local.widgets.installed.version |
default(0) }}"
widgets_latest_version: "latest"
In your case you won't need to check those local facts (unless you want to)
but you can set as many facts as you want. The last modified time of the
/etc/ansible/facts.d/widgets.fact file will tell you when it was last
changed. If you rerun the playbook with the same version it will not
update that time, if you store other facts you may also want to store times
with them if they are all in the same facts file.
I hope that this helps,
Adam
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4e8af014-df2b-469c-8ca1-ff149c86bc1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.