The basics here are that task includes can pass parameters, playbook
includes never had that implemented.







On Sun, Feb 23, 2014 at 1:33 AM, anatoly techtonik <[email protected]>wrote:

> On Friday, February 21, 2014 11:47:36 PM UTC+3, Michael DeHaan wrote:
>>
>> - include: showdist.yml host='localhost'
>>
>>
>> You have no variables here, so this is not an inventory variable
>> substitution issue.
>>
>> But you would be setting a variable called "host" that has no special
>> meaning for Ansible.
>>
>> Minor pet-peeve/process note  -- when you say something doesn't work,
>> share what it did, and what it expected to do.  I don't know what "doesn't
>> work" means 80% of the time.
>>
>
> Let me try again:
>
> *playbook.yml *- this file doesn't change
> ---
> - hosts: localhost
> - include: showdist.yml host='localhost'
>
>
> *showdist.yml* - first version:
> ---
>
>> - hosts: "{{ host | default('otherhost') }}"
>
>>   tasks:
>
>>   - name: show OS version info
>     debug: msg="ping"
>
> $  ansible-playbook -i hosts showdist.yml
> PLAY [otherhost] ***
> $  ansible-playbook -i hosts playbook.yml
> PLAY [localhost] ***
> PLAY [localhost] ***
>
> Not that the last PLAY message is from showdist.yml included from
> playbook.yml
> It run correctly against 'localhost'. For me - this works as expected
>
> Now I add vars section in *showdist.yml v2*:
> ---
> - hosts: "{{ host | default('otherhost') }}"
>   vars:
>     - irrelevant: "just for vars section"
>   tasks:
>   - debug: msg="ping"
>
> And showdist.yml stops to run against localhost when included from
> playbook.yml
>
> $  ansible-playbook -i hosts showdist.yml
> PLAY [otherhost] ***
> $  ansible-playbook -i hosts playbook.yml
> PLAY [localhost] ***
> PLAY [otherhost] ***
>
> Why?
>
> --
> 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/3ad226f6-b421-4975-a2c5-2b33cc5bb20b%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAEVJ8QMh6dkfevexJ5LxcL60gLAL9uD87Zaw%2BPqX4tYRCeeumA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to