I tried this and it isn't working as expected:

test.yml
---
- include: 1.yml
  when: type == '1'
- include: 2.yml
  when: type == '2'


1.yml
---
- name: "1"
  hosts: localhost
  tasks:
    - debug: msg="1"


2.yml
---
- name: "2"
  hosts: localhost
  tasks:
    - debug: msg="2"

Command:
ansible-playbook test.yml -e "type=1"

Output:
PLAY [1] 
********************************************************************** 


GATHERING FACTS 
*************************************************************** 
ok: [localhost]


TASK: [debug msg="1"] 
********************************************************* 
ok: [localhost] => {
    "msg": "1"
}


PLAY [2] 
********************************************************************** 


GATHERING FACTS 
*************************************************************** 
ok: [localhost]


TASK: [debug msg="2"] 
********************************************************* 
ok: [localhost] => {
    "msg": "2"
}


PLAY RECAP 
******************************************************************** 
localhost                  : ok=4    changed=0    unreachable=0    failed=0 
  

-Tristan

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1748390a-77e8-4358-99e6-dfe02efc91db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to