我需要在 YAML 文件中以可变的次数写入一些行:
- name: Retry a task until a certain condition is met
lineinfile:
path: /root/file
insertafter: '^listeners:'
line: 'iteration #iteration_number++'
retries: {{ a_variable }}
delay: 10
我还想将每次迭代的执行次数写入文件。类似于以下 for 循环:
for i in {1..a_variable}
do
echo "i"
done
如何追踪循环中的当前位置?