# Forcing a task to not show as "changed"

**URL:** <https://forum.ansible.com/t/forcing-a-task-to-not-show-as-changed/13066>\
**Category:** Ansible Project\
**Created:** [July 4, 2013, 10:31am UTC](https://forum.ansible.com/t/forcing-a-task-to-not-show-as-changed/13066 "2013-07-04T10:31:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Dunham](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andrew\_Dunham](https://forum.ansible.com/u/Andrew_Dunham)\
**Post date:** [July 4, 2013, 10:31am UTC](https://forum.ansible.com/t/forcing-a-task-to-not-show-as-changed/13066/1 "2013-07-04T10:31:02Z")

</div>

Hi there,

I have a playbook with the following set of tasks:

- name: Check if the GPG key is present  
sudo: yes  
sudo\_user: foobar  
command: gpg --list-keys XXXXX  
ignore\_errors: true  
register: gpg\_result

- name: Import the signing GPG key  
sudo: yes  
sudo\_user: foobar  
command: gpg --import /home/foobar/pubkey.gpg  
when: gpg\_result|failed

The idea being, check if a GPG key is present, and, if not, import it. I’d like to add some sort of flag that states that the first task (which always runs) doesn’t actually modify anything, and thus shouldn’t be counted as having “changed”. Is there a way to do this? Note that this isn’t the only example - the general pattern of “run command, depending on result, run other(s)” has come up before.

Thanks,  
–Andrew D

---

<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:** [July 4, 2013, 1:07pm UTC](https://forum.ansible.com/t/forcing-a-task-to-not-show-as-changed/13066/2 "2013-07-04T13:07:02Z")

</div>

There is a pull request in queue for this:

[https://github.com/ansible/ansible/pull/3389](https://github.com/ansible/ansible/pull/3389)

---

<div class="post-metadata">

**Author:** ![Randy\_Syring](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@Randy\_Syring](https://forum.ansible.com/u/Randy_Syring)\
**Post date:** [September 26, 2013, 2:40am UTC](https://forum.ansible.com/t/forcing-a-task-to-not-show-as-changed/13066/3 "2013-09-26T02:40:54Z")

</div>

This has now been implemented:

[http://www.ansibleworks.com/docs/playbooks2.html#overriding-changed-result](http://www.ansibleworks.com/docs/playbooks2.html#overriding-changed-result)  
[https://github.com/stoned/ansible/blob/eb45f07ae3a64a8ff675bd0846d156522c1e14fc/test/playbook-changed\_when.yml](https://github.com/stoned/ansible/blob/eb45f07ae3a64a8ff675bd0846d156522c1e14fc/test/playbook-changed_when.yml)
