How to make an error non fatal in dry mode?

I have a playbook with the following two tasks:

  • copy:
    src: libpasswdqc.so.0
    dest: /usr/lib/libpasswdqc.so.0
    owner: root
    group: bin
    mode: 0755

  • file:
    src: ./libpasswdqc.so.0
    dest: /usr/lib/libpasswdqc.so
    owner: root
    group: root
    state: link

It is not possible to check this playbook, because the first task does not copy the file while running in dry mode and the second throws a fatal error:

fatal: [xxxxxxxx]: FAILED! => {“changed”: false, “failed”: true, “msg”: “src file does not exist, use "force=yes" if you really want to create the link: /usr/lib/./libpasswdqc.so.0”, “path”: “/usr/lib/libpasswdqc.so”, “src”: “./libpasswdqc.so.0”, “state”: “absent”}

How to make the error non fatal during dry runs?

you can add:

ignore_errors: “{{ansible_check_mode|bool}}”

or

register: myresult
failed_when: myresult|failed and not ansible_check_mode