I can create an array wars like so ( I *THINK* it's an array, pretty sure
it's an array )
$cat roles/test/tasks/main.yml
---
- name: "find war files on node"
shell: "find /var/www/Container*/ -name '*.war' -type f -print"
register: output
- name: "set facts"
set_fact:
wars: "{{ output.stdout_lines }}"
- name: print wars
command: echo "{{ item }}"
with_items: wars
which gives me:
TASK: [test | print wars]
*****************************************************
changed: [127.0.0.1] => (item=/var/www/ContainerA/service2.war)
changed: [127.0.0.1] => (item=/var/www/ContainerA/service1.war)
changed: [127.0.0.1] => (item=/var/www/ContainerB/service2.war)
changed: [127.0.0.1] => (item=/var/www/ContainerB/service1.war)
I want to munge wars into an array of key/value pairs that look like this:
services:
- { container: 'ContainerA', service: 'service2' }
- { container: 'ContainerA', service: 'service1' }
- { container: 'ContainerB', service: 'service1' }
- { container: 'ContainerB', service: 'service2' }
Any ideas on how I can accomplish this ? I am having a lot of trouble
trying to map an array into another array of key value pairs.
I haven't been able to figure out substring matching either.
I can probably do this directly in the jinja template, but I'd like to just
have a fact with the 'services' array.
Thanks.
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/35252693-a230-4274-852a-f375a5f5da49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.