Note that you cannot do variable substitution when including one playbook inside another.
Variable substitution works, just not with inventory variables, which confuses people a lot.
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.
---
- hosts: "{{ host | default('localhost') }}"
tasks:
- name: show OS version info
debug: msg="{{ansible_distribution}} {{ansible_distribution_version}}"
---
- hosts: localhost
- include: showdist.yml
---
- hosts: localhost
- include: showdist.yml host='localhost'
- include: showdist.yml host='localhost'
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
- 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.
---
- hosts: localhost
- include: showdist.yml host='localhost'
---
- hosts: "{{ host | default('otherhost') }}"
tasks:
- name: show OS version info
debug: msg="ping"
---- hosts: "{{ host | default('otherhost') }}" vars: - irrelevant: "just for vars section" tasks: - debug: msg="ping"
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3ad226f6-b421-4975-a2c5-2b33cc5bb20b%40googlegroups.com.
The basics here are that task includes can pass parameters, playbook includes never had that implemented.
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4e69ba68-5e68-4066-bf22-e5a4594b3886%40googlegroups.com.