yaml - Ansible - Create a list with items and | list -


i trying make list inside uri body. using |list not append list items new list.

my task:

uri:   url: "{{ url }}"   method: "post"   body:     policies:       - "default"       - "{{ item | selectattr('policy', 'defined') | map(attribute='policy') | list }}"     body_format: json   with_items:     - "{{ policy_config }}" 

but gives me:

policies:   - \"default\"   - \"[u'app1', u'app2']\" 

so not appending app1 & app2 separate list items new one. how can solve issue?

thanks lot in advance!

construct single list. 1 of possible examples:

policies: "{{ ['default'] + item | selectattr('policy', 'defined') | map(attribute='policy') | list }}" 

if json_query available in setup, shorter:

policies: "{{ ['default'] + item | json_query('[].policy') }}" 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -