Tôi đang gặp phải sự cố silliest. Tôi không thể tìm ra cách kiểm tra boolean trong tệp tác vụ Ansible 2.2.Sử dụng True False với Ansible Khi khoản
Trong vars/main.yml
, tôi có:
destroy: false
Trong playbook, tôi có:
roles:
- {'role': 'vmdeploy','destroy': true}
Trong tập tin công việc, tôi đã điều sau đây:
- include: "create.yml"
when: "{{ destroy|bool }} == 'false'"
tôi đã thử các kết hợp khác nhau bên dưới:
when: "{{ destroy|bool }} == false"
when: "{{ destroy|bool }} == 'false'"
when: "{{ destroy|bool == false}}"
when: "{{ destroy == false}}"
when: "{{ destroy == 'false'}}"
when: destroy|bool == false
when: destroy|bool == 'false'
when: not destroy|bool
Trong tất cả các trường hợp trên, tôi vẫn nhận được:
statically included: .../vmdeploy/tasks/create.yml
gỡ lỗi đầu ra:
- debug:
msg: "{{ destroy }}"
---
ok: [atlcicd009] => {
"msg": true
}
Các kết quả mong muốn, là nó sẽ bỏ qua bao gồm.