I found the answer in a previous 
post: https://groups.google.com/d/topic/ansible-project/NGXcbyQvz-Y/discussion

So register stores the variable even if the task is skipped, and this is 
the intended behaviour.

I was able to do what I want with one longer shell command, although I was 
expecting something more elegant:

  tasks:
   - name: test
     shell: if [ {{ ansible_hostname | match("^xy-") }} == True ]; then 
echo /opt/cache/www; else if [ {{ ansible_hostname | match("^az-") }} == 
True ]; then echo /mnt/code/www; fi; fi
     register: www_data

   - debug: var=www_data.stdout
     when: www_data.rc == 0

-- 
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/e0bb4dfe-3ee7-41dc-a5dd-a6d05f7f4f4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to