# suppress "changed" for register'ed variables

**URL:** <https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471>\
**Category:** Ansible Project\
**Created:** [September 26, 2023, 9:09pm UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471 "2023-09-26T21:09:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzagrabe](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@mzagrabe](https://forum.ansible.com/u/mzagrabe)\
**Post date:** [September 26, 2023, 9:09pm UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/1 "2023-09-26T21:09:03Z")

</div>

Greetings,

I currently register some variables via:

cat roles/configure\_account\_environment/tasks/main.yaml

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [September 26, 2023, 9:29pm UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/2 "2023-09-26T21:29:52Z")

</div>

Sounds like you need to use `changed_when: false` here - [https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_error\_handling.html#defining-changed](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_error_handling.html#defining-changed)

---

<div class="post-metadata">

**Author:** ![mzagrabe](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@mzagrabe](https://forum.ansible.com/u/mzagrabe)\
**Post date:** [September 26, 2023, 11:08pm UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/3 "2023-09-26T23:08:30Z")

</div>

Thanks for the help Richard!

Any ideas on changing “skipped” to “ok”:

[…]

TASK [common : set editor to vim] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [zed]

[…]

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
zed : ok=23 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0

Again, thank you for the great assistance.

Cheers,

-m

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [September 27, 2023, 12:00am UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/4 "2023-09-27T00:00:20Z")

</div>

Check the `when:` condition on the skipped task. Why is the condition `false`?

---

<div class="post-metadata">

**Author:** ![mzagrabe](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@mzagrabe](https://forum.ansible.com/u/mzagrabe)\
**Post date:** [September 27, 2023, 12:17am UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/5 "2023-09-27T00:17:35Z")

</div>

Here are the two tasks:

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [September 27, 2023, 12:39am UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/6 "2023-09-27T00:39:13Z")

</div>

> Here are the two tasks:
> 
> - 
> 
> name: get editor realpath  
> shell: realpath /usr/bin/editor

Use `command` here instead of `shell`

> register: editor\_realpath  
> changed\_when: False  
> tags:
> 
> - vim
> 
> - 
> 
> name: set editor to vim  
> command: update-alternatives --set editor /usr/bin/vim.nox  
> when: editor\_realpath.stdout != ‘/usr/bin/vim.nox’  
> tags:
> 
> - vim
> 
> I guess I’d like the “set editor to vim” task to be “OK” if it is already set to vim, but it is showing up as “skipped”.

Not sure how to do that

---

<div class="post-metadata">

**Author:** ![mzagrabe](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@mzagrabe](https://forum.ansible.com/u/mzagrabe)\
**Post date:** [September 27, 2023, 1:17am UTC](https://forum.ansible.com/t/suppress-changed-for-registered-variables/38471/7 "2023-09-27T01:17:43Z")

</div>

> > Here are the two tasks:
> > 
> > - 
> > 
> > name: get editor realpath  
> > shell: realpath /usr/bin/editor
> 
> Use `command` here instead of `shell`

Sure thing.

> > register: editor\_realpath  
> > changed\_when: False  
> > tags:
> > 
> > - vim
> > 
> > - 
> > 
> > name: set editor to vim  
> > command: update-alternatives --set editor /usr/bin/vim.nox  
> > when: editor\_realpath.stdout != ‘/usr/bin/vim.nox’  
> > tags:
> > 
> > - vim
> > 
> > I guess I’d like the “set editor to vim” task to be “OK” if it is already set to vim, but it is showing up as “skipped”.
> 
> Not sure how to do that

Fair enough. You’ve been very helpful, Richard. Thanks again for all the help!

-m
