redhat-openstack / infrared

Plugin based framework that aims to provide an easy-to-use CLI for Ansible based projects
https://infrared.readthedocs.io/en/latest/index.html
Apache License 2.0
99 stars 96 forks source link

empty bridged network fails with: 'nic_name' is undefined #406

Open andreaskaris opened 3 years ago

andreaskaris commented 3 years ago
fatal: [hypervisor]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'nic_name' is undefined\n\nThe error appears to be in '/home/infrared/.infrared/plugins/virsh/tasks/bridged_network.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# https://jamielinux.com/docs/libvirt-networking-handbook/bridged-network.html#bridged-network\n- name: validate required nic is present\n  ^ here\n"}

https://github.com/redhat-openstack/infrared/blob/26a35df2323a6476ae922ee0f31c605a56289634/plugins/virsh/provision_networks.yml#L67

    - name: create bridged network
      include_tasks: tasks/bridged_network.yml
      vars:
          nic_settings: "{{ item }}"
          nic_data: "{{ (item.nic == '') | ternary(hostvars[inventory_hostname]['ansible_' + ansible_default_ipv4.interface],
              hostvars[inventory_hostname]['ansible_' + item.nic]|default('')) }}"
      with_items:
          "{{ networks.values() | selectattr('forward', 'defined') | selectattr('forward', 'equalto', 'bridge') | list }}"
      when: "networks is defined"

https://github.com/redhat-openstack/infrared/blob/26a35df2323a6476ae922ee0f31c605a56289634/plugins/virsh/tasks/bridged_network.yml#L4

- name: validate required nic is present
  fail:
      msg: "Cannot find bridge nic: {{ nic_name }}"
  when: nic_data == ''