我有这本Ansible剧本,我需要一些帮助。基本上在V1中,我检查RAM是否与它通过的CPUid 8168匹配并且效果很好但是对于v2我通过网络速度进行检查,因为它们都是1Gig连接,它试图再次检查它但很明显失败了,因为他们有不同的RAM。我怎么能告诉Ansible基本上只说when: speed.stdout == '1000Mb/s' and is not cpudID=8168
- name: Check V1
set_fact:
total_mem: "{{memory.stdout }}"
failed_when: "{{total_mem|int / 1000|int }} < 190"
when: cpuid.stdout == '8168'
- name: Check v2
set_fact:
total_mem: "{{ memory.stdout }}"
failed_when: "{{ (total_mem|int / 1000)|int }} < 250"
ignore_errors: yes
when: speed.stdout == '1000Mb/s'
答案 0 :(得分:0)
根据Conditionals上的Ansible文档,多个when
语句可与逻辑and
结合使用...
when: speed.stdout == '1000Mb/s' and cpudID != 8168
...或指定为列表:
when:
- speed.stdout == '1000Mb/s'
- cpudID != 8168