Hi,
When a shell command is executed, Ansible consider it as a modifying
action. It’s a sensible default, because it can’t predict the command
output, but I’m wondering if there’s a way to declare a command as
safe/read-only?
This already exists to declare that something doesn’t change something.
changed_when: False
If you mean to run it always in check mode, this is:
always_run: True
You can use change_when:
example: change_when: False
If you are able to predict the output using changed_when with register
can be useful:
For example:
...
register: cmd_result
changed_when: cmd_result.stdout != ""
John Jarvis <john@jarv.org> writes:
If you are able to predict the output using changed_when with register
can be useful:
For example:
...
register: cmd_result
changed_when: cmd_result.stdout != ""
I completely missed these options!
Thanks to Michael, Philippe, and John.