There is an omit
filter which can help in bypassing some parameters if they are not applicable. For this purpose, we can define a variable that will be set to true
for Ansible version 2.8 or greater. Then this variable can be passed to the quiet
parameter of assert
module in combination with omit
.
Example:
- set_fact:
quiet_assert: true
when: ansible_version.full is version('2.8', '>=')
- assert:
that:
- true
quiet: "{{ quiet_assert|default(omit) }}"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…