Developers: Improvements to --check mode (pseudo dry run), now working for more module types, how to instrument the others...

Hi everyone,

I've started going through some modules and teaching the --check mode
to work with them.

For those not paying attention to previous threads, this means you can
run a playbook or ansible command on a remote system and see if
something would have changed, without making any changes.

The corresponding flag --diff can also show unified diffs if any
template files would have changed.

You can see what kinds of changes these involve by looking at what I
did for the group module here:

https://github.com/ansible/ansible/commit/ad89ab7c5da100d0902da4899b29bf0ad405f2fd

If folks want to help with other modules they own, that would be GREAT.

If you don't add "supports_check_mode" to the Module Constructor, the
module will report "skipped" when used with --check, which basically
means "hey, I don't know how to do this".

As I've said before, Ansible is a process orchestration engine, so a
lot of complex playbooks with register variables make almost no sense
with --check mode anyway. For instance, command
mode operations will be skipped. However, it seemed nice to have
this feature for those people who are just doing classical config
management. Be advised it is only a simulation.

The modules I have instrumented so far include:
user
group
service
file
copy
template
ping
command/shell (always skip, never run)

I think for this to be really complete, we should probably do yum and
apt. I will take a look at yum next.

I would be happy if there isn't a lot of module coverage outside of
this, but I would also welcome contributions like what I did to the
group module (patch linked above) to any other module.

In doing this I had to make some changes to OS modules I do not
normally test (FreeBSD, NetBSD, etc) so those with those platforms I
would love it if --check mode (and non check mode) could get some
testing just to make sure we didn't miss anything.

I also have a ticket open to make --diff work better in unicode
situations and will be looking at that shortly.

--Michael

I've also just taught yum to understand --check mode.

If someone wants to follow my lead and add this to apt, that would be great!

(And again, any other modules you feel like teaching --check mode
tricks, are fair game)

--Michael