Thanks Brain that worked for me.

On Wednesday, November 21, 2018 at 11:40:16 PM UTC+5:30, 
[email protected] wrote:
>
> Hi,
>
> I am trying to pass each item from a list using "with_items" and trying to 
> control it using "loop_control" & "loop_vars".But when I have defined 
> another "loop_control" & "loop_vars" along with "with_items".The playbook 
> is throwing error.Below are the 2 playbooks details:
>
> #####  main.yml  ####
> ---
> - hosts: localhost
>   gather_facts: no
>   tasks:
>   - include_tasks: inner2.yml
>     with_items:
>       - 1
>       - 2
>       - 3
>     loop_control:
>       loop_var: outer_item
>
>   - include_tasks: inner2.yml
>     with_items:
>       - 4
>       - 5
>       - 6
>     loop_control:
>       loop_var: outer_item2
>
> #####  inner.yml  ####
> ---
>   - debug:
>       msg: "outer item={{ outer_item }} inner item={{ item }} outer2 
> item={{ outer_item2 }}"
>     with_items:
>       - a
>       - b
>       - c
>
> And the output is
>
>
> PLAY [localhost] 
> ********************************************************************************************************
>
> TASK [include_tasks] 
> ****************************************************************************************************
> included: /etc/ansible/playbooks/inner2.yml for localhost
> included: /etc/ansible/playbooks/inner2.yml for localhost
> included: /etc/ansible/playbooks/inner2.yml for localhost
>
> TASK [debug] 
> ************************************************************************************************************
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with 
> an undefined variable. The error was: 'outer_item2' is undefined\n\nThe 
> error appears to have been in '/etc/ansible/playbooks/inner2.yml': line 2, 
> column 5, but may\nbe elsewhere in the file depending on the exact syntax 
> problem.\n\nThe offending line appears to be:\n\n---\n  - debug:\n    ^ 
> here\n\nexception type: <class 
> 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'outer_item2' is 
> undefined"}
> to retry, use: --limit @/etc/ansible/playbooks/main2.retry
>
> PLAY RECAP 
> **************************************************************************************************************
> localhost                  : ok=3    changed=0    unreachable=0    
> failed=1   
>
> TASK: include_tasks ----------------------------------------------------- 
> 0.06s
> TASK: debug ------------------------------------------------------------- 
> 0.03s
> TASK: include_tasks ----------------------------------------------------- 
> 0.06s
> TASK: debug ------------------------------------------------------------- 
> 0.03s
> Playbook run took 0 days, 0 hours, 0 minutes, 0 seconds
>
>
> Can anyone help me how can I pass "outer_item2" values also.
>
> Thanks,
> Acharya Tejaswi Indurthy.
>

-- 
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/bac4ae0f-05fb-4a94-876a-32255d3e9f24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to