Registered variables and templates

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

- name: gather some facts
  command: ls -l /etc
  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

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.