On 23. mars 2017 13:44, Bhavin Parmar wrote:
Hey Kai,
Thanks for your guidance. I am just looking for vol-0e0516ea962XXXXX as
output. Same way I have to grab various parts from output, to convert them
in key : value pair, to store in YAML file.
Please, can you suggest how to only get the particular part? Like we can
get with following manual way?
- debug: var=ec2_snap.results[0].invocation.module_args.device_name
- debug: var=ec2_snap.results[0].item
- debug: var=ec2_snap.results[0].volume_id
- debug: var=ec2_snap.results[0].snapshot_id
- debug: var=ec2_snap.results[1].invocation.module_args.device_name
- debug: var=ec2_snap.results[1].item
- debug: var=ec2_snap.results[1].volume_id
- debug: var=ec2_snap.results[1].snapshot_id
I'm not sure what you mean, because your loop did that.
The output on the screen will always contain more than just the value,
but the variable itself contains just the value.
- name: Print out variables in a loop with debug module
debug: msg="### The output ###: {{
item.invocation.module_args.device_name }} - {{ item.item }} - {{
item.volume_id }} - {{ item.snapshot_id }}"
with_items: "{{ ec2_snap.results }}"
This will print the values on one line divided by dash.
And it would be easy to identify since the line start with "### The
output ###:"
--
Kai Stian Olstad
--
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/18aa94de-3f66-6203-2c16-e376c2aa588c%40olstad.com.
For more options, visit https://groups.google.com/d/optout.