# Parse registered output into a variable?

**URL:** <https://forum.ansible.com/t/parse-registered-output-into-a-variable/23129>\
**Category:** Ansible Project\
**Created:** [November 29, 2016, 8:30pm UTC](https://forum.ansible.com/t/parse-registered-output-into-a-variable/23129 "2016-11-29T20:30:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![burns498](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@burns498](https://forum.ansible.com/u/burns498)\
**Post date:** [November 29, 2016, 8:30pm UTC](https://forum.ansible.com/t/parse-registered-output-into-a-variable/23129/1 "2016-11-29T20:30:55Z")

</div>

Hello - Is there a way to parse registered output into a variable?

Pseudo Code:

`  
tasks:

- name: Sample Task  
command: ‘blah’  
register: output
- debug: var=output.stdout

`

> TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> ok: [target] =\> {  
> “output.stdout”: “Foo: Bar”  
> }

So I can easily register and use “Foo: Bar”. But is there a way where I can just store “Bar” for later use?  
For context, the command uses some black box vendor provided classes so I’m unable to change the actual output. I need to work with what is presented.

Thank you!

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 29, 2016, 8:34pm UTC](https://forum.ansible.com/t/parse-registered-output-into-a-variable/23129/2 "2016-11-29T20:34:12Z")

</div>

set\_fact:  
just\_bar: “{{ output.stdout.split()|last }}”

Or any other number of things. The key there is to use set\_fact to set a new variable.

---

<div class="post-metadata">

**Author:** ![burns498](https://avatars.discourse-cdn.com/v4/letter/b/b487fb/32.png) [@burns498](https://forum.ansible.com/u/burns498)\
**Post date:** [November 29, 2016, 8:49pm UTC](https://forum.ansible.com/t/parse-registered-output-into-a-variable/23129/3 "2016-11-29T20:49:13Z")

</div>

Ah - works like a charm. Thank you for the speedy response!
