# Group project? Adding --check mode to core modules

**URL:** <https://forum.ansible.com/t/group-project-adding-check-mode-to-core-modules/12323>\
**Category:** Ansible Project\
**Created:** [February 10, 2013, 4:47am UTC](https://forum.ansible.com/t/group-project-adding-check-mode-to-core-modules/12323 "2013-02-10T04:47:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 10, 2013, 4:47am UTC](https://forum.ansible.com/t/group-project-adding-check-mode-to-core-modules/12323/1 "2013-02-10T04:47:56Z")

</div>

Currently right now only the file/template and copy modules support  
check mode, which allows you to see if something would change without  
making changes.

It would be desirable if all modules could do this.

Would folks like to each take a core module and see about converting  
it? (Similar to what we did when adding the built-in documentation  
strings?)

Basically all you have to do is:

add supports\_check\_mode=True to the bottom of the AnsibleModule constructor

AND

wherever a module decides to set "changed" = True, and before actually  
making a change, do something like:

if self.check\_mode:  
&nbsp;&nbsp;&nbsp;&nbsp;module.exit\_json(changed=True)

That's it, though various modules will require some different kinds of  
handling depending on how they are implemented.

You will notice the file module doesn't have much code about "check  
mode" in it, because that code happens to live in  
lib/ansible/module\_common. This will not be the case for all modules.

In any event, help on this would be much appreciated, and then we can  
say all (or most) of our modules support --check mode and you have a  
better idea of what changes would (or would not) occur when running  
without --check.

--Michael

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [February 10, 2013, 5:03am UTC](https://forum.ansible.com/t/group-project-adding-check-mode-to-core-modules/12323/2 "2013-02-10T05:03:13Z")

</div>

I'd like to make the yum module behave appropriately with --check but it will take some time to do it properly.

If anyone wants to look into doing it, do not wait for me, I'm a bit covered up at the moment so I don't want to be a blocker to useful work getting done 🙂

-sv

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 10, 2013, 2:41pm UTC](https://forum.ansible.com/t/group-project-adding-check-mode-to-core-modules/12323/3 "2013-02-10T14:41:07Z")

</div>

Yeah, it's not a concern, we have the whole release to get this in.

I started to look at service but it seemed to want for a little bit of  
refactoring to make it easier (it needs it anyway).

Priority would be apt, yum, service, user, and group. (As mentioned  
file, template, copy, already done). Anything else is a bonus!

---

<div class="post-metadata">

**Author:** ![Tim\_Bielawa](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Tim\_Bielawa](https://forum.ansible.com/u/Tim_Bielawa)\
**Post date:** [February 10, 2013, 5:39pm UTC](https://forum.ansible.com/t/group-project-adding-check-mode-to-core-modules/12323/4 "2013-02-10T17:39:55Z")

</div>

I will check out pause and nagios. Should be trivial.
