When should a module say 'changed'

I have a module I am working on for our product the Cumulus OS where we check routes and make logical decisions based on the result.
e.g. I make a config change to a node within my network and then check another node in that network to make sure the path through the ‘changed’ node is or is not taken.

Working with a team mate here at Cumulus Networks the only time the module can fail is when the command can’t be run (improper output is retrieved, or the command just goes fubar). I think it should fail whenever we don’t get a result we desire. I also think this particular module should never ever say ‘changed’ since it is not changing any code on the network nodes (debian boxes) at any time. It relies on other modules or playbooks to make changes and then checks for what you desire with this module (cl_prefix_check). Its just a ‘checker’ module that looks at the routing table in various ways to simplify playbooks people will write.

My question is this assumption correct:
Can a module never make something like ‘changed=1’. I feel as changed means a config (file) has been changed?

(I know how to code this, but not sure if it follows ansible’s idea of changed/fail/ok, etc)

-S

Hi Sean!

Basically I view it should say changed when it affects the configuration or state of the remote machine, not if it needs to just run some commands.

I would concur that if it can’t successfully affect a change, this is a case when it should be marked as a failure (fail_json).

If the module is just returning “fact” type information, the usual convention would be to have it end in “_facts” and not return changed=True.

So if the question is can a module never change anything, yes that’s totally ok.

Does this sort of answer the question?

Let me know if not or if I am misunderstanding.

Thanks!