Hi Matt,
I am facing one more issue here, iam providing the conditional statemt in
my playbook,,, but both are executing even if the conditions is true or
false.
- name: System_ipaddress_mac_combinations present inside CSV_IP_MAC_DETAILS
fact
debug:
msg : The system_ip-MAC combinations "{{ item }}" is present in the
CSV_IP_MAC_DETAILS fact, If present it will be skipped and VALIDATION
SUCCESS
when: item.find("csv_ip_mac_details") != -1
with_items:
- "{{ system_ip_mac_details }}"
- name: System_ipaddress_mac_combinations not present inside
CSV_IP_MAC_DETAILS fact
debug:
msg : The system_ip-MAC combinations "{{ item }}" is not present in the
CSV_IP_MAC_DETAILS fact So VALIDATION FAILED
when: item.find("csv_ip_mac_details") == -1
with_items:
- "{{ system_ip_mac_details }}"
TASK [Interface-Mac-Validation : System_ipaddress_mac_combinations present
inside CSV_IP_MAC_DETAILS fact] **************************
skipping: [BVI15CA2] => (item= 10.174.206.157: 02:15:0a:ae:ce:9d
10.145.19.4: 02:15:0a:91:13:04 172.16.7.52: 02:15:ac:10:07:34 )
skipping: [BVI15CA2]
TASK [Interface-Mac-Validation : System_ipaddress_mac_combinations not
present inside CSV_IP_MAC_DETAILS fact] **********************
ok: [BVI15CA2] => (item= 10.174.206.157: 02:15:0a:ae:ce:9d 10.145.19.4:
02:15:0a:91:13:04 172.16.7.52: 02:15:ac:10:07:34 ) => {
"msg": "The system_ip-MAC combinations \" 10.174.206.157:
02:15:0a:ae:ce:9d 10.145.19.4: 02:15:0a:91:13:04 172.16.7.52:
02:15:ac:10:07:34 \" is not present in the CSV_IP_MAC_DETAILS fact So
VALIDATION FAILED"
}
On Tuesday, July 2, 2019 at 8:41:14 PM UTC+5:30, Rakesh Parida wrote:
>
> Hi Mat,
>
> Thanks for the suggestion.
> That worked for me as a charm :)
>
> On Tuesday, July 2, 2019 at 8:30:50 PM UTC+5:30, Matt Martz wrote:
>>
>> when statements are already implicitly wrapped in jinja2 templating.
>>
>> Effectively you just need:
>>
>> ```
>> when: item in csv_ip_mac_details
>> ```
>>
>> As simple as removing the {{ }} jinja2 delimiters.
>>
>> On Tue, Jul 2, 2019 at 9:58 AM Rakesh Parida <[email protected]>
>> wrote:
>>
>>> How can i insert value of variables using with items in conditional
>>> checks
>>>
>>> name: system_ipaddress_mac_combinations present inside fact
>>> debug:
>>> msg : The system_ip-MAC combinations "{{ item }}" is present in
>>> teh fact
>>> when: '{{ item }} in {{ csv_ip_mac_details }}'
>>> with_items:
>>> - "{{ system_ip_mac_details }}"
>>>
>>> TASK [system_ipaddress_mac_combinations present inside fact]
>>> ***********************************************************************************************************
>>> [WARNING]: conditional statements should not include jinja2 templating
>>> delimiters such as {{ }} or {% %}. Found: {{ item }} in {{
>>> csv_ip_mac_details }}
>>>
>>> --
>>> 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/21685cee-f595-4e88-b2bd-ce6da0c14de2%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/ansible-project/21685cee-f595-4e88-b2bd-ce6da0c14de2%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Matt Martz
>> @sivel
>> sivel.net
>>
>
--
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/3081f7dd-5976-423c-9416-c7ef3568fbdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.