# Marking commands as read-only

**URL:** <https://forum.ansible.com/t/marking-commands-as-read-only/14175>\
**Category:** Ansible Project\
**Created:** [December 18, 2013, 7:23pm UTC](https://forum.ansible.com/t/marking-commands-as-read-only/14175 "2013-12-18T19:23:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giorgio\_Valoti](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@Giorgio\_Valoti](https://forum.ansible.com/u/Giorgio_Valoti)\
**Post date:** [December 18, 2013, 7:23pm UTC](https://forum.ansible.com/t/marking-commands-as-read-only/14175/1 "2013-12-18T19:23:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 18, 2013, 7:29pm UTC](https://forum.ansible.com/t/marking-commands-as-read-only/14175/2 "2013-12-18T19:29:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PhilEv](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@PhilEv](https://forum.ansible.com/u/PhilEv)\
**Post date:** [December 18, 2013, 7:30pm UTC](https://forum.ansible.com/t/marking-commands-as-read-only/14175/3 "2013-12-18T19:30:22Z")

</div>

You can use change\_when:

example: change\_when: False

---

<div class="post-metadata">

**Author:** ![John\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@John\_Jarvis](https://forum.ansible.com/u/John_Jarvis)\
**Post date:** [December 18, 2013, 8:03pm UTC](https://forum.ansible.com/t/marking-commands-as-read-only/14175/4 "2013-12-18T20:03:29Z")

</div>

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 != ""

---

<div class="post-metadata">

**Author:** ![Giorgio\_Valoti](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@Giorgio\_Valoti](https://forum.ansible.com/u/Giorgio_Valoti)\
**Post date:** [December 18, 2013, 8:18pm UTC](https://forum.ansible.com/t/marking-commands-as-read-only/14175/5 "2013-12-18T20:18:21Z")

</div>

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.
