0
我有一個jinja模板,需要填充我的服務器的輔助ip。ansible ipv4輔助IP過濾
我試着運行下面的代碼,它比我所需要的要多一點點。
tasks:
- name: debug2
debug: msg={{ ansible_enp0s8_iface1.ipv4_secondaries }}
結果
ok: [localhost] => {
"msg": [
{
"address": "172.16.2.20",
"broadcast": "172.16.2.255",
"netmask": "255.255.255.0",
"network": "172.16.2.0"
}
]
}
然而,當我運行以下
tasks:
- name: debug2
debug: msg={{ ansible_enp0s8_iface1.ipv4_secondaries.address }}
我得到以下致命錯誤指示 「地址」 是不確定的。我不知道爲什麼會這樣,因爲它與主界面
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'list object' has no attribute 'address'\n\nThe error appears to have been in '/root/test.yml': line 15, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n #debug: msg={{ ansible_enp0s8_iface1.ipv4_secondaries.address }}\n - name: debug1\n ^here\n"}
謝謝。正是我在找什麼。我會對元素提示做一個心理記錄。 – crusadecoder