我想在ansible playbook中的iosxr_配置行中使用变量。我尝试了以下代码
- hosts: 116.119.4.1
connection: local
vars:
trapdests: []
tasks:
- name: show version
register: command_out
iosxr_command:
commands: "sh ipv4 interface brief | include Loopback0"
- debug:
var: command_out.stdout
- name: trapping the Loopback ip
register: trapdests
set_fact:
trapdests: "{{[item.split()[1]]}}"
with_items: "{{command_out.stdout_lines}}"
- debug:
var: trapdests
# tasks:
- name: enable PCEP
iosxr_config:
lines:
- traffic-eng
- pcc
- source-address ipv4 "{{item}}"
- pce address ipv4 100.67.249.67
- precedence 100
with_items: "{{trapdests}}"
parents: segment-routing
基本上我想在这个命令的末尾使用变量-->;源地址ipv4“{item}}”。但我得到了以下错误:
TASK [enable PCEP] **********************************************************************************************************************************************************************************************
fatal: [116.119.4.1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined\n\nThe error appears to have been in '/home/cisco/pcep_enble_test_2.yml': line 20, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# tasks:\n - name: enable PCEP\n ^ here\n"}
to retry, use: --limit @/home/cisco/pcep_enble_test_2.retry
PLAY RECAP ******************************************************************************************************************************************************************************************************
116.119.4.1 : ok=5 changed=0 unreachable=0 failed=1
谁能帮帮我吗。提前谢谢
看起来你有语法错误。With_项目必须在任务级别:
相关问题 更多 >
编程相关推荐