现象
- name: Do smthg with countvar
command: echo "{{ item }}"
with_sequence: start=1 end={{ countvar.stdout|int }}
when: countvar.stdout|int >= 1
ansible 执行报错 to count backwards make stride negative
处理办法
先进行判断,在进行with_sequence
循环,可以避免{{ countvar.stdout|int }}
值为0时这个报错
- name: Do smthg with countvar
command: echo "{{ item }}"
with_sequence: start=1 end={{ countvar.stdout|int }}
when: countvar.stdout|int >= 1