# Registered variables and templates

**URL:** <https://forum.ansible.com/t/registered-variables-and-templates/14110>\
**Category:** Ansible Project\
**Created:** [December 10, 2013, 8:16am UTC](https://forum.ansible.com/t/registered-variables-and-templates/14110 "2013-12-10T08:16:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giorgio\_Valoti](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@Giorgio\_Valoti](https://forum.ansible.com/u/Giorgio_Valoti)\
**Post date:** [December 10, 2013, 8:16am UTC](https://forum.ansible.com/t/registered-variables-and-templates/14110/1 "2013-12-10T08:16:16Z")

</div>

Hi all,  
If I want to use the result of a command within a template I use  
`register`:

- name: gather some facts  
&nbsp;&nbsp;command: ls -l /etc  
&nbsp;&nbsp;register: etc\_contents

and then, in my template:

# {{ ansible\_managed }}  
{% for d in etc\_contents.stdout\_lines %}  
{{d}}  
{% endfor %}

It works OK, but it would be cleaner to register  
`etc_contents.stdout_lines` directly as a variable with list value. Is  
there a way to do this?

Ciao

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [December 19, 2013, 4:23pm UTC](https://forum.ansible.com/t/registered-variables-and-templates/14110/2 "2013-12-19T16:23:25Z")

</div>

You could assign stdout\_lines to a fact:

- set\_fact: foo="{{ result.stdout\_lines }}"

But then you would have to figure out a way to split the string in your template:

"[u'1', u'2', u'3', u'4', u'5']"

So it's probably better to stick with what you have and maybe file a feature request for set\_fact to allow types other than string.
