# local\_action and register

**URL:** <https://forum.ansible.com/t/local-action-and-register/12804>\
**Category:** Ansible Project\
**Created:** [May 14, 2013, 10:16am UTC](https://forum.ansible.com/t/local-action-and-register/12804 "2013-05-14T10:16:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [May 14, 2013, 10:16am UTC](https://forum.ansible.com/t/local-action-and-register/12804/1 "2013-05-14T10:16:01Z")

</div>

Hi there

I have some troubles to get register variable from local\_action. Here is what I have:

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [May 14, 2013, 10:27am UTC](https://forum.ansible.com/t/local-action-and-register/12804/2 "2013-05-14T10:27:18Z")

</div>

​Where you running that playbook in check mode?

​

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [May 14, 2013, 10:54am UTC](https://forum.ansible.com/t/local-action-and-register/12804/3 "2013-05-14T10:54:43Z")

</div>

Yes, I were running it in check mode.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [May 14, 2013, 11:44am UTC](https://forum.ansible.com/t/local-action-and-register/12804/4 "2013-05-14T11:44:39Z")

</div>

​That's why the command tasks are skipped (they don't support check mode).  
And then the variable doesn't get registered, which is why it fails in the  
next step.

Serge​

---

<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:** [May 14, 2013, 12:20pm UTC](https://forum.ansible.com/t/local-action-and-register/12804/5 "2013-05-14T12:20:31Z")

</div>

" only\_if: “$status.rc != 0"”

BTW, only _if is extremely dated syntax. In 1.1 this was improved with when\_integer, and in 1.2 (current development release but many many people run from source and it’s quite stable now) both only\_if and when_\* are deprecated.

when: status:rc != 0

What you want in this case is actually:

when: status is defined and status.rc != 0

---

<div class="post-metadata">

**Author:** ![Edgars](https://avatars.discourse-cdn.com/v4/letter/e/f17d59/32.png) [@Edgars](https://forum.ansible.com/u/Edgars)\
**Post date:** [May 14, 2013, 12:40pm UTC](https://forum.ansible.com/t/local-action-and-register/12804/6 "2013-05-14T12:40:03Z")

</div>

Ok, thanks everyone. I am very suspicious and always run check mode 🙂

I am aware of only\_if and when, but since both of them did not work, I left only\_if.

Regarding outdated syntax - perhaps --syntax-check should warn about deprecated syntax? It’s not always possible to track all changes, but --syntax-check seems to be a godd way how to warn about them!?

Edgars

---

<div class="post-metadata">

**Author:** ![Zack\_Perry](https://avatars.discourse-cdn.com/v4/letter/z/54ee81/32.png) [@Zack\_Perry](https://forum.ansible.com/u/Zack_Perry)\
**Post date:** [July 9, 2013, 8:24pm UTC](https://forum.ansible.com/t/local-action-and-register/12804/7 "2013-07-09T20:24:57Z")

</div>

But as of today, July 9, 2013, the examples for the debug module are still using the only\_if expression?

– Zack

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [July 9, 2013, 9:28pm UTC](https://forum.ansible.com/t/local-action-and-register/12804/8 "2013-07-09T21:28:15Z")

</div>

Easily fixed with a pull request. I've been doing that for the docs I come across that are dated.

-jlk

---

<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 10, 2013, 1:04am UTC](https://forum.ansible.com/t/local-action-and-register/12804/9 "2013-07-10T01:04:49Z")

</div>

I have a ticket on this already. Will get to it if there is not a pull request.
