# ansible --check mode for shift left

**URL:** <https://forum.ansible.com/t/ansible-check-mode-for-shift-left/37077>\
**Category:** Ansible Project\
**Created:** [September 7, 2022, 3:36pm UTC](https://forum.ansible.com/t/ansible-check-mode-for-shift-left/37077 "2022-09-07T15:36:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Button](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@Steve\_Button](https://forum.ansible.com/u/Steve_Button)\
**Post date:** [September 7, 2022, 3:36pm UTC](https://forum.ansible.com/t/ansible-check-mode-for-shift-left/37077/1 "2022-09-07T15:36:14Z")

</div>

Hi,

I’m trying to add some “shift left” to my Ansible, so that mistakes don’t creep in. Firstly, I thought I would run --check (perhaps as a git pre-commit hook or perhaps in Jenkins pipeline eventually). So, I tried it locally. Unfortunately it bombs out in several places, as some tasks are reliant on the output of other tasks. Not a great problem, as I’ve added

when: not ansible\_check\_mode

to those tasks.

Is there a better way of achieving this? Particularly it would be useful to check that variables are set to something sensible (catch typos or just missed variables) BEFORE it goes into production. We have vars files based on environments, so these don’t get checked until we actually deploy to that environment.

---

<div class="post-metadata">

**Author:** ![mahespth](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mahespth/32/252_2.png) [@mahespth](https://forum.ansible.com/u/mahespth)\
**Post date:** [September 7, 2022, 3:53pm UTC](https://forum.ansible.com/t/ansible-check-mode-for-shift-left/37077/2 "2022-09-07T15:53:23Z")

</div>

Hi Steve,

Take a look at check\_mode and assess your playbook to see which features are you can safely change, ie those that do not make change.

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_checkmode.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html)

Regards  
Steve Maher

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [September 7, 2022, 3:59pm UTC](https://forum.ansible.com/t/ansible-check-mode-for-shift-left/37077/3 "2022-09-07T15:59:04Z")

</div>

Providing default values for missing outputs might be a better option  
in some cases. It would be good to see the particular case(s).

---

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [September 7, 2022, 3:59pm UTC](https://forum.ansible.com/t/ansible-check-mode-for-shift-left/37077/4 "2022-09-07T15:59:16Z")

</div>

Try a dry run with —check on a remote host (—limit $HOST). I forgot, —check does a dry run.

Mike
