On 12/10/2013 03:16 AM, Giorgio Valoti wrote:
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
--
Giorgio Valoti


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.

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to