Group project? Adding --check mode to core modules

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:
    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

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 :slight_smile:

-sv

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!

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