- name: integration/become/sudo_flags_failure.yml hosts: test-targets tasks: - name: Verify behaviour for bad sudo flags. shell: whoami become: true ignore_errors: true register: out vars: ansible_become_flags: --derps - name: Verify raw module output. assert: that: - out.failed - >- 'sudo: no such option: --derps' in out.msg or out.module_stdout is match("sudo: invalid option -- '-'") or out.module_stderr is match("sudo: invalid option -- '-'") or out.module_stdout is match("sudo: unrecognized option [`']--derps'") or out.module_stderr is match("sudo: unrecognized option [`']--derps'") fail_msg: out={{out}} tags: - sudo - sudo_flags_failure