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.

Reply via email to