--- - hosts: localhost gather_facts: "{{ setup | default(False) }}" validate_argspec: "{{ spec | default(omit) }}" tasks: - name: "task 1" fail: - name: "task 2" debug: msg: bar - assert: that: ansible_facts.gather_subset == ["all"] when: setup | default(False)