There's no way to dynamically append to a list presently.

Since you've shared an abstract example, it might be a good idea to explain
the use case and we can share some other ways to model it?




On Fri, Dec 13, 2013 at 11:38 PM, Ross Becker <[email protected]> wrote:

> So, I'm looking for a way to add items to a list conditionally.  The point
> of the list is to be provided for a with_items clause.  I know I can
> evaluate python in jinja expressions, but it seems that those changes may
> be localized to the expression where they are evaluated.
>
> Here's a general idea of what I'm attempting to do.  I have tested this
> playbook, and the output at the end is "foo", "bar", "baz", with "harpo"
>  and "groucho" nowhere to be found, and yes, I've verified that
> enable_harpo and enable_groucho evaluate to true.
> ===================
> - hosts: configurator
>   user: root
>   gather_facts: False
>
>   vars:
>     svc_list: [ "foo", "bar", "baz" ]
>
>   tasks:
>     - name: checkharpo
>       debug: msg="Foo more {{ svc_list.append('harpo') }}"
>       when: enable_harpo
>
>     - name: checkgroucho
>       debug: msg="Foo more {{ svc_list.append('groucho') }}"
>       when: enable_groucho
>
>     - name: listme
>       debug: msg="Message for service $item"
>       with_items: svc_list
> ==================================
>
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Michael DeHaan <[email protected]>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

-- 
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 [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to