Python (and Jinja) practices short circuit evaluation. So move the is
defined test ahead of the numeric test, and you should be ok.
On Wed, Apr 2, 2014 at 8:04 AM, Marcin Prączko marcin.prac...@gmail.comwrote:
Good morning.
I am trying using local facts for tracking version of the role, and run
this role only if version increased (version kept locally within role
comparing with version from local fatcs).
So this is how is working:
Role folder
- vars/main.yml
- tasks/main.yml
So this is example for: vars/main.yml
---
module:
name: apache
version: 1.0.4
status: Installed
And this is a task which writes this variables to local facts on remote
machine:
- name: Write variable to json file
copy: content={{ module }} dest=/etc/ansible/facts.d/{{ module.name}}.fact
owner=root group=root mode=0644
And json is written to localfacts - which is working well.
Now I am trying to do something like that in main playbook:
roles:
- { role: test_roleversion,
when: module.version ansible_local.apache.version }
This is working well if local facts already exists with 'version'
variable. Hower when file is not there ansible complain about not defined
variable:
fatal: [IP-HERE] = error while evaluating conditional: module.version
ansible_local.apache version
*Question:*
How to run role only if:
- module.version ansible_local.apache.version (- this come from local
facts), or
- ansible_local.apache.version is not defined?
Following example does't work :(
roles:
- { role: test_roleversion,
when: module.version ansible_local.apache.version or
ansible_local.apache.version not defined }
Thanks for helping in advance.
Best regards,
Marcin Praczko
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ef032110-df93-47e6-a733-85717dc400d0%40googlegroups.comhttps://groups.google.com/d/msgid/ansible-project/ef032110-df93-47e6-a733-85717dc400d0%40googlegroups.com?utm_medium=emailutm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAEVJ8QMh_0zgHGNEaC8-vz%2B6Ux30SAws97DHS_uRxqtxWffMpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.