Group project? Adding --check mode to core modules

47 views
Skip to first unread message

Michael DeHaan

unread,
Feb 9, 2013, 11:47:56 PM2/9/13
to ansible...@googlegroups.com
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

Seth Vidal

unread,
Feb 10, 2013, 12:03:13 AM2/10/13
to ansible...@googlegroups.com
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



Michael DeHaan

unread,
Feb 10, 2013, 9:41:07 AM2/10/13
to ansible...@googlegroups.com
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!
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Tim Bielawa

unread,
Feb 10, 2013, 12:39:55 PM2/10/13
to ansible...@googlegroups.com
I will check out pause and nagios. Should be trivial.


--
--Tim Bielawa
http://lnx.cx
Reply all
Reply to author
Forward
0 new messages