Thanks Brian.

if condition is apply to the tasks level, the we will expect the task  - 
debug: msg="incude playbook0.yml" at playbook0.yml should be skipped, but 
actually it is not.

Here is result:

$ ansible-playbook -i hosts playbook.yml --extra-vars="run1=true run0=false"

PLAY [test-servers] 
***********************************************************

GATHERING FACTS 
***************************************************************
ok: [testserver]

TASK: [debug msg="incude playbook0.yml"] 
**************************************
ok: [testserver] => {
    "msg": "incude playbook0.yml"
}

PLAY [test-servers] 
***********************************************************

GATHERING FACTS 
***************************************************************
ok: [testserver]

TASK: [debug msg="incude playbook1.yml"] 
**************************************
ok: [testserver] => {
    "msg": "incude playbook1.yml"
}

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

Thanks
Jack


On Tuesday, November 4, 2014 10:02:06 AM UTC-8, Brian Coca wrote:
>
> Conditions on include don't apply to the include itself, it is applied to 
> the tasks included
> On Nov 4, 2014 1:00 PM, "jack" <[email protected] <javascript:>> wrote:
>
>> I have problem at conditional include playbook:
>>
>> For example, I am following three simple playbooks:
>>
>> playbook0.yml:
>> ---
>> - hosts: test-servers
>>   tasks:
>>
>>   - debug: msg="incude playbook0.yml"
>>
>> playboo1.yml:
>> ---
>> - hosts: test-servers
>>   tasks:
>>
>>   - debug: msg="incude playbook1.yml"
>>
>> playbook.yml:
>> ---
>>
>> - include: playbook0.yml
>>   when: run0 == 'true'
>>
>> - include: playbook1.yml
>>   when: run1 == 'true'
>>
>> I try to run my playbook:
>> ansible-playbook -i hosts playbook.yml --extra-vars="run1=true run0=false"
>>
>> But it looks like the condition is not working. playbook0 and playbook1 
>> are always included no matter what condition I set. What I did wrong? Is it 
>> possible to include another playbook conditionally?
>>
>> Thanks
>> Jack
>>
>> -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/5e7cb3ae-0ba5-4e5b-8b7d-ceae56abad8e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/5e7cb3ae-0ba5-4e5b-8b7d-ceae56abad8e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/c3b34306-f818-4bf8-8cdd-e16d2a0fd4fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to