3
Imは、when文に使用している指定された文字列の出力変数を検索できません。以下のコードは、出力変数の文字列 "distribute-list"をチェックするはずですが、プレイブックを実行するとエラーになります。ここで出力レジスタの文字列を一致させるための条件付きの使用(可能)
fatal: [192.168.3.252]: FAILED! => {"failed": true, "msg": "The conditional check 'output | search(\"distribute-list\")' failed. The error was: Unexpected templating type error occurred on ({% if output | search(\"distribute-list\") %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in '/home/khibiny/test4.yml': line 26, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^here\n"}
が問題を引き起こしているコードです:
- ios_command:
commands: show run | sec ospf
provider: "{{cli}}"
register: output
- debug:
msg: "{{output.stdout_lines}}"
when: output | search("distribute-list")
は、いくつかの助けをお願い申し上げます。前もって感謝します。
ありがとうございます。別のフォーラムでこれを掲示し、助けを得ることができませんでした。 Stack Overflowで掲示され、1時間以内に私は助けを得る。どうもありがとう – techkid