ansible 执行报错 to count backwards make stride negative 的处理办法

现象

- 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
posted @ 2020-10-22 14:45  hiyang  阅读(264)  评论(0编辑  收藏  举报