私はこれを知っています。私はこのようになりますYAMLあります可能性のある「サブ要素の検索で辞書が必要です」
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
を、私は
- 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
のようにこれは、常にで失敗していますansibleタスクがあります。
fatal: [fe1.prod.somedomain.de]: FAILED! => {"failed": true, "msg": "subelements lookup expects a dictionary, got 'network_interface_scripts | default([])'"}
を私は辞書のためのオンラインバリデータを試してみましたそれはそれが有効なYAMLだと言った。私は何が欠けていますか?なぜこれを辞書と認識しないのですか?
編集: それは文字列リテラル「network_interface_scripts」としてnetwork_interface_scriptsの治療です:Ansibleバージョンは2.2.0.0で、これは
をごansibleバージョンは何ですか?それは2.2以上ですか? – helloV
with_ステートメントの裸の変数は、SO ... 2 days old [answer](http://stackoverflow.com/a/41001940/2795592)で1日おきにポップアップします。 –
おかげで、検索は役に立たなかった。 –