Hi, I'm trying to deal with non existing variable when i use --tags (so lot of task are skipped)
I have read many time the "http://docs.ansible.com/ansible/playbooks_conditionals.html#loops-and-conditionals", specially this part : If you need to skip the whole task depending on the loop variable being defined, used the |default filter to provide an empty iterator: - command: echo {{ item }} with_items: "{{ mylist|default([]) }}" when: item > 5 On my site.yml, i load several (if exist) several task on pre_tasks (so before roles): hosts: all pre_tasks: - name : check if need to load custom task local_action: stat path="tasks/{{ item }}.yml" with_items: - "{{ group_names }}" become: no register: file - name : "Loading custome task with {{ group_names }}" include: "{{ item.stat.path }}" when: "{{ item.stat.exists }}" with_items: "{{ file.results }}" normaly, It's working great but if i skip this part (via --tags) it's failed with : 'file' is undefined i don't known how to try write my with_items condition : with_items: "{{ file|default([]) }}" : is skipping but not work on normal condition (without the --tags ) with_items: "{{ file|default([]).results }}" : template error while templating string with_items: "{{ file.results|default([]) }} : 'file' is undefined Do you have a idea how to deal with this kind of problem ? -- 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/4f46e5cf-4579-4d58-8cb9-543da087f3cd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
