Hello

here's my playbook, I am looking for interface without IP:

---
- hosts: all
  vars:
    interface_name: ""
    ipaddress: "{{ ansible_default_ipv4.address }}"
  tasks:
  - name: enumerate interfaces
    debug: 
      msg: "{{ item }}"
    with_items:
      "{{ ansible_interfaces }}"

  - debug:
      var:  ansible_{{ item }} 
    with_items:
      "{{ ansible_interfaces }}"
 
  - name: find interface without an ip
    set_fact:
      desired_interface_name: "{{ item }}"
    when:
      ansible_{{ item }}.ipv4 is defined and (ansible_{{ item }}|length>0)
    with_items: 
      "{{ ansible_interfaces }}"

  - name: print result
    debug:
      var: desired_interface_name

it works, but yells me a warn:
[WARNING]: conditional statements should not include jinja2 templating 
delimiters such as {{ }} or {% %}. Found: ansible_{{item }}.ipv4 is defined 
and (ansible_{{ item }}|length>0)

just out for curiosity, what's the proper way?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a4fd7513-32ab-4422-87f8-42ff49bb0506n%40googlegroups.com.

Reply via email to