I'm at my wits ends with this. I have YAML that looks like this:
network_interface_scripts:
-
interface: eth0
lifecycle_entries:
-
commands:
- "route add -net 172.17.2.0 netmask 255.255.255.0 gw 172.17.70.1 eth0"
- "route add -net 10.102.0.0 netmask 255.255.0.0 gw 172.17.70.1 eth0"
script_name: interface_eth0_up
trigger_on: post-up
-
commands:
- "route delete -net 172.17.2.0 netmask 255.255.255.0 gw 172.17.70.1 eth0"
- "route delete -net 10.102.0.0 netmask 255.255.0.0 gw 172.17.70.1 eth0"
script_name: interface_eth0_down
trigger_on: pre-down
and I have an ansible task that's like
- name: Check that trigger_on has valid value
fail: msg="trigger_on has invalid value. Allowed values are pre-up, up, post-up, pre-down, down and post-down"
when: item.1.trigger_on != "pre-up" and item.1.trigger_on != "up" and item.1.trigger_on != "post-up" and item.1.trigger_on != "pre-down" and item.1.trigger_on != "down" and item.1.trigger_on != "post-down"
with_subelements:
- network_interface_scripts | default([])
- lifecycle_entries
This always fails with:
fatal: [fe1.prod.somedomain.de]: FAILED! => {"failed": true, "msg": "subelements lookup expects a dictionary, got 'network_interface_scripts | default([])'"}
I tried an online validator for the dictionary, which said it was valid YAML. What am I missing? Why does ansible not recognize this as a dictionary?
edit: Ansible version is 2.2.0.0, search didn't turn up anything useful ... sry if this has been asked before