Even though the code is more structured, it can be a little tricky to troubleshoot state modules. This is because you need to test all four types of return results:
True – The resource is already correctly configured
None – The resource is not correctly configured, and
test
mode is TrueTrue with changes – The resource was not correctly configured, but now it is
False – The resource could not be correctly configured
What makes this even trickier is that in the course of troubleshooting, you are likely to change configuration to be correct, and then incorrect, and then back again several times before the code is right. I suggest breaking it up.
Your first step, after setting up your defaults, is to check whether the resource is correctly configured. This is likely to require you to manually toggle settings to make sure it is properly checking both desired and undesired configuration. Add two returns: one for True
and one for False
:
ret = {...