debops / ansible-ifupdown

Manage network interface configuration in /etc/network/interfaces
GNU General Public License v3.0
25 stars 14 forks source link

debops.ifupdown/env fails, opaque error #66

Closed pwetzel closed 7 years ago

pwetzel commented 7 years ago

I attempted to make one change to my network configuration, and now Ansible run terminates with the error message below. This happened to me once before, and it seems to me that some kind of wiping out the facts on the host (ts440 below) finally allowed it to work again. It was many troubleshooting attempts over many hours, and when it started working again it didn't make sense to me then. Now that it's back, I am at a loss.

I have deleted the entire /etc/ansible folder on the host, re-run bootstrap, tried several variations of the configuration syntax. No change in the error. I can't figure out what this error is pointing to. I'm hoping it's clearer to someone else.

I'm filing this as an issue because 1) I am desperate and 2) I can't believe there isn't a bug of some sort that allows this role to be so brittle in my very simple use case.

fatal: [ts440]: FAILED! => {"failed": true, "msg": "{{ lookup(\"template\", \"lookup/ifupdown__ferm__dependent_rules.j2\", convert_data=False) | from_yaml }}: An unhandled exception occurred while running the lookup plugin 'template'. Error was a <class 'ansible.errors.AnsibleError'>, original message: {{ lookup(\"template\", \"lookup/ifupdown__combined_interfaces.j2\", convert_data=False) | from_yaml }}: An unhandled exception occurred while running the lookup plugin 'template'. Error was a <class 'ansible.errors.AnsibleError'>, original message: {{ ifupdown__default_interfaces_map[ifupdown__interface_layout] | d({}) }}: {u'static': {u'external': {u'iface': u'{{ ansible_default_ipv4.interface|d(\"\") }}', u'dns_nameservers': u'{{ ansible_dns.nameservers|d(False) }}', u'dns_search': u'{{ ansible_dns.search|d(False) }}', u'gateway': u'{{ ansible_default_ipv4.gateway|d(\"\") }}', u'address': u'{{ (ansible_default_ipv4.address|d(\"\") + \"/\" + ansible_default_ipv4.netmask|d(\"\")) }}', u'inet6': u'auto', u'inet': u'static'}}, u'manual': {}, u'dynamic': {u'internal': {u'state': u'{{ \"present\" if ifupdown__internal_interface in ansible_interfaces else \"ignore\" }}', u'iface': u'{{ ifupdown__internal_interface }}', u'inet6': u'auto', u'inet': u'dhcp'}, u'external': {u'state': u'{{ \"present\" if ifupdown__external_interface in ansible_interfaces else \"ignore\" }}', u'iface': u'{{ ifupdown__external_interface }}', u'inet6': u'auto', u'inet': u'dhcp'}, u'br1': {u'state': u'{{ \"absent\" if (ansible_local|d() and ansible_local.ifupdown|d() and ansible_local.ifupdown.interface_layout|d() and ansible_local.ifupdown.interface_layout == \"bridge\") else \"ignore\" }}'}, u'br0': {u'state': u'{{ \"absent\" if (ansible_local|d() and ansible_local.ifupdown|d() and ansible_local.ifupdown.interface_layout|d() and ansible_local.ifupdown.interface_layout == \"bridge\") else \"ignore\" }}'}}, u'bridge': {u'internal': {u'state': u'{{ \"present\" if ifupdown__internal_interface in ansible_interfaces else \"ignore\" }}', u'iface': u'{{ ifupdown__internal_interface }}', u'inet6': False, u'inet': u'manual'}, u'external': {u'state': u'{{ \"present\" if ifupdown__external_interface in ansible_interfaces else \"ignore\" }}', u'iface': u'{{ ifupdown__external_interface }}', u'inet6': False, u'inet': u'manual'}, u'br1': {u'state': u'{{ \"present\" if ifupdown__internal_interface in ansible_interfaces else \"ignore\" }}', u'bridge_ports': u'{{ ifupdown__internal_interface }}', u'forward': True, u'type': u'bridge', u'inet6': u'auto', u'inet': u'dhcp'}, u'br0': {u'state': u'{{ \"present\" if ifupdown__external_interface in ansible_interfaces else \"ignore\" }}', u'bridge_ports': u'{{ ifupdown__external_interface }}', u'forward': True, u'type': u'bridge', u'inet6': u'auto', u'inet': u'dhcp'}}}: {{ ansible_local.ifupdown.internal_interface if (ansible_local|d() and ansible_local.ifupdown|d() and ansible_local.ifupdown.internal_interface|d()) else (lookup(\"template\", \"lookup/ifupdown__internal_interface.j2\", convert_data=False) | from_yaml) }}: An unhandled exception occurred while running the lookup plugin 'template'. Error was a <class 'ansible.errors.AnsibleError'>, original message: {{ ansible_local.ifupdown.external_interface if (ansible_local|d() and ansible_local.ifupdown|d() and ansible_local.ifupdown.external_interface|d()) else (lookup(\"template\", \"lookup/ifupdown__external_interface.j2\", convert_data=False) | from_yaml) }}: An unhandled exception occurred while running the lookup plugin 'template'. Error was a <class 'yaml.representer.RepresenterError'>, original message: cannot represent an object: eth0"}

My inventory variables:

ifupdown__host_interfaces:
  'eth0':
    type: 'ether'
    inet: 'manual'
    inet6: False

  'br0':
    type: 'bridge'
    inet: 'dhcp'
    inet6: 'auto'
    auto: True
    forward: False
    bridge_ports: [ 'eth0' ]

I have nothing specified for ferm.

drybjed commented 7 years ago

It seems to be an issue with YAML parser that has been resolved in the Ansible GitHub repository but it's not yet present in official Ansible releases. What Ansible version do you use? Can you try using Ansible from stable-2.2 branch on GitHub? This seems to be the working one right now.

pwetzel commented 7 years ago

Yes, thank you, it was ansible/ansible#20253. Running stable-2.2 resolves it. I guess I just got lucky that one time it went through a couple weeks ago.

pwetzel commented 7 years ago

I was using 2.2.1 from Jessie Backports (2.2.1.0-1~bpo8+1) before, and that did not work. I ran it this evening with stable-2.2 (1eda29b) and it did work.