Hi all, I need to get the id of all available volumes in amazon aws, to
make it I have created the following
---
- name: "volumes"
hosts: localhost
gather_facts: no
tasks:
- name: "list avail volumes"
amazon.aws.ec2_vol_info:
region: us-east-1
filters:
status: available
register: aws_volume
- name: "show"
debug:
msg: "{{ aws_volume.volumes[0].id }}"
The output of the variable only shows me one result and should show me all.
ok: [localhost] => {
"msg": "vol-0c7b50c2896e422d4"
}
when I call the variable the results are many example:
ok: [localhost] => {
"msg": {
"changed": false,
"failed": false,
"volumes": [
{
"attachment_set": [],
"create_time": "2019-05-30T15:49:14.238000+00:00",
"encrypted": false,
"id": "vol-xxxxxxxxxx",
"iops": 100,
"region": "us-east-1",
"size": 32,
"snapshot_id": "snap-xxxxxxxx",
"status": "available",
"tags": {
"Backup": "false",
"Environment": "PROD",
"Name": "app2"
"Zone": "1C"
},
"type": "gp2",
"zone": "us-east-1c"
},
{
"attachment_set": [],
"create_time": "2019-07-18T18:06:16.555000+00:00",
"encrypted": false,
"id": "vol-xxxxxxxxx",
"iops": 100,
"region": "us-east-1",
"size": 32,
"snapshot_id": "snap-xxxxxxxxxxxx",
"status": "available",
"tags": {
"Backup": "true",
"Environment": "PROD",
"Name": "app1"
},
"type": "gp2",
"zone": "us-east-1c"
},
I should use to loop over the variable "aws_volume" and then call it as {{
item.volumes[0]. id}}?
Any helps?
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAGUDtnkSQxnygkCzH599qOWPNFmrEkVgMAC0UrcvEA7-a7u2aQ%40mail.gmail.com.