Я хочу использовать переменную в строках iosxr_config в ansible playbook. Я пробовал следующий код.
- 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
В основном я хочу использовать переменную в конце этой команды ---> source-address 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
Может кто-нибудь помочь мне, пожалуйста. Заранее спасибо.