“When” condition on Ansible playbook doesn't work as expected using operators

后端 未结 1 644
长发绾君心
长发绾君心 2020-12-12 06:21

Below playbook use conditional statement with operators in Ansible. When I run the playbook, it never takes/validates the condition instead it consider the last set_fact val

1条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 07:10

    Fix your indentation. when is not an argument of a set_fact action, but of a task:

    - name: SHMALL value for MEM less than 16G
      set_fact:
        shmall: 3670016
      when: ansible_memtotal_mb|int <= 16384
    
    - name: SHMALL value for MEM is between 16G and 32G
      set_fact:
        shmall: 7340032
      when: ansible_memtotal_mb|int > 16384 and ansible_memtotal_mb|int <= 32768
    

    0 讨论(0)
提交回复
热议问题