I understand, I could make it work, but not by using the ec2 snapshot
module.
I try to save a key as a variable but the result is empty
ok: [localhost] => {
"ansible_facts": {
"snap_id": ""
},
"changed": false
}
---
- name: "test"
hosts: localhost
gather_facts: no
vars:
aws_volume_id:
- vol-xxxxxxxxxx
tasks:
- name: "create snapshot test"
amazon.aws.ec2_snapshot:
volume_id: "{{ item }}"
wait_timeout: 900
snapshot_tags:
MarkedForDeletion: true
register: snapshot_info
with_items: "{{ aws_volume_id }}"
- set_fact:
snap_id: "{{ snapshot_info | json_query('snapshot_id')}}"
- name: "Debug"
debug:
msg: "{{ snap_id }}"
This is the output
changed: [localhost] => (item=vol-xxxxxxxxxxxx) => {
"ansible_loop_var": "item",
"changed": true,
"invocation": {
"module_args": {
"aws_access_key": null,
"aws_ca_bundle": null,
"aws_config": null,
"aws_secret_key": null,
"debug_botocore_endpoint_logs": false,
"description": null,
"device_name": null,
"ec2_url": null,
"instance_id": null,
"last_snapshot_min_age": 0,
"profile": null,
"region": null,
"security_token": null,
"snapshot_id": null,
"snapshot_tags": {
"MarkedForDeletion": true
},
"state": "present",
"validate_certs": true,
"volume_id": "vol-xxxxxxxxxxx",
"wait": true,
"wait_timeout": 900
}
},
"item": "vol-xxxxxxxxx",
"snapshot_id": "snap-xxxxxxxxxxxx",
What am I doing wrong?
--
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/CAGUDtnmTWBvTZGUD2RG4kSAxv6WgDM637sFFb8kkX1Aid5t5kg%40mail.gmail.com.