I'm trying to pass variable data from one value to another task in Ansible and it fails due to square brackets, I've tried to see how to remove them but nothing helped. My Playbook related part is:
- name: List Volumes
ec2_vol_facts:
region: "{{ region }}"
filters:
attachment.instance-id: "{{ ec2_id }}"
register: vol_list
- name: Tagging XVDF
ec2_vol:
region: "{{ region }}"
id: "{{ vol_list.volumes | json_query('[?attachment_set.device==`xvdf`].id')|list }}"
instance: "{{ ec2_id }}"
state: present
tags:
org_instance: "{{ ec2_id }}"
mapping: "xvdf"
This eventually failed with the following error:
"msg": "InvalidParameterValue: Value (['vol-0506598']) for parameter volumes is invalid. Expected: 'vol-...'."
Other parameters are passing correctly, so what is missing here? Thanks for the help.