【发布时间】:2022-01-04 05:32:50
【问题描述】:
下面是我的任务代码:
- name: Add calculation nodes of different groups to the list
set_fact:
list_of_all_calculate_node: "{{ list_of_all_calculate_node | default([]) + ['random_calculate_host' + ('{{ item }}' | string ) ] }}"
loop: "{{ range(1,5) }}"
- name: Print list_of_all_calculate_node
debug:
var: "{{ item }}"
loop: "{{ list_of_all_calculate_node }}"
错误类型:致命
TASK [Print list_of_all_calculate_node]
fatal: [*.*.*.*]: FAILED! => {"msg": "['random_calculate_host2', 'random_calculate_host3', 'random_calculate_host4', 'random_calculate_host{{ item }}']: 'item' is undefined"}
预期的输出应该是:
['random_calculate_host1','random_calculate_host2', 'random_calculate_host3', 'random_calculate_host4']
【问题讨论】: