# Variable gets registered even if when clause is false

**URL:** <https://forum.ansible.com/t/variable-gets-registered-even-if-when-clause-is-false/27118>\
**Category:** Ansible Project\
**Created:** [March 26, 2018, 4:01pm UTC](https://forum.ansible.com/t/variable-gets-registered-even-if-when-clause-is-false/27118 "2018-03-26T16:01:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKPhil](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@MKPhil](https://forum.ansible.com/u/MKPhil)\
**Post date:** [March 26, 2018, 4:01pm UTC](https://forum.ansible.com/t/variable-gets-registered-even-if-when-clause-is-false/27118/1 "2018-03-26T16:01:31Z")

</div>

In a playbook, a Variable gets registered even if “when” clause is false…Is this a bug?

Consider this playbook

`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 26, 2018, 4:04pm UTC](https://forum.ansible.com/t/variable-gets-registered-even-if-when-clause-is-false/27118/2 "2018-03-26T16:04:10Z")

</div>

The when: clause affects task execution, while register: puts into a  
variable the status and output of a task.

So 'skipped' is a 'valid status of a task', which is what then is put  
into the registered variable, this way subsequent tasks can do this:

when: registeredvar is skipped

to execute another task when previous one is skipped (or not + other  
conditions).

---

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [March 26, 2018, 4:05pm UTC](https://forum.ansible.com/t/variable-gets-registered-even-if-when-clause-is-false/27118/3 "2018-03-26T16:05:02Z")

</div>

What the value of ‘now’ variable?

---

<div class="post-metadata">

**Author:** ![mhalano](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mhalano/32/1815_2.png) [@mhalano](https://forum.ansible.com/u/mhalano)\
**Post date:** [March 26, 2018, 4:07pm UTC](https://forum.ansible.com/t/variable-gets-registered-even-if-when-clause-is-false/27118/4 "2018-03-26T16:07:56Z")

</div>

Nevermind. (:
