Skip Ansible task when running in check mode?

Ansible 2.1 supports ansible_check_mode magic variable which is set to True in check mode (official docs). This means you will be able to do this:

- file:
    state: link
    src: '{{ filename }}'
    dest: latest
  when: not ansible_check_mode

or

- file:
    state: link
    src: '{{ filename }}'
    dest: latest
  ignore_errors: '{{ ansible_check_mode }}'

whichever you like more.

Leave a Comment

tech