Any idea how I can access any element from keys list above?
It’s because keys
is a method on dict
and almost every “object” in ansible/jinja2 is a dict
. You can side-step that method resolution via the ["keys"]
syntax:
- debug:
msg: key_id is {{ vault_aws_kms["keys"][0].key_id }}
the followup question in the comments about the quotes would be
method A:
- set_fact:
my_key_id: '{{ vault_aws_kms["keys"][0].key_id }}'
method B:
- set_fact:
my_key_id: "{{ vault_aws_kms['keys'][0].key_id }}"
method C
- set_fact:
my_key_id: >-
{{ vault_aws_kms["keys"][0].key_id }}
CLICK HERE to find out more related problems solutions.