On Friday, February 21, 2014 10:59:38 PM UTC+3, Brian Coca wrote:
>
> include gets evaluated before hosts are included and you cannot use a
> inventory variable (host dependant) in the include.
>
> Think of it as a 'preprocessing macro' more than a task.
>
I still don't get it. I have the file showdist.yml:
---
> - hosts: "{{ host | default('localhost') }}"
> tasks:
> - name: show OS version info
> debug: msg="{{ansible_distribution}} {{ansible_distribution_version}}"
Now I include it from main playbook.yml:
---
> - hosts: localhost
> - include: showdist.yml
It fails with:
PLAY [otherhost]
**************************************************************
skipping: no hosts matched
But when I do this:
---
> - hosts: localhost
> - include: showdist.yml host='localhost'
It works. And I am surprised, because for more complicated file it didn't
work.
--
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].
For more options, visit https://groups.google.com/groups/opt_out.