Check mode for Windows modules

23 views
Skip to first unread message

hod...@gmail.com

unread,
May 4, 2016, 4:01:22 PM5/4/16
to Ansible Project
Is there a way to implement check mode in a custom Windows module? I didn't see anything in the documentation about it, and none of the several core modules I checked contained an example.

Thanks,
Eric

J Hawkesworth

unread,
May 4, 2016, 6:04:49 PM5/4/16
to Ansible Project
There's no reason I can think of why it couldn't be done, but I don't think any core windows modules support check mode at the moment.

Might be worth a check of the extras modules if you are interested in adding support.

I don't particularly miss the lack of check mode. As I have got more familiar with powershell I do sometimes use ansible to run the raw module to check things using a powershell 1 liner. It would be good to have though. Are there specific cases where you would want to use check mode?

Jon

Matt Davis

unread,
May 5, 2016, 11:15:55 AM5/5/16
to Ansible Project
Yes, the Windows module API has supported check mode since 2.0. To express your module's support for check mode, pass $true as the second arg to Parse-Args (supports_check_mode). Modules that don't pass that will exit out with "skipped" from Parse-Args when check mode is requested.

To see if you're actually in check mode from your module code, look for the module parameter "_ansible_check_mode" to be $true.
Reply all
Reply to author
Forward
0 new messages