# Cannot extract specific value from imported task

**URL:** <https://forum.ansible.com/t/cannot-extract-specific-value-from-imported-task/44145>\
**Category:** Get Help\
**Tags:** azure\
**Created:** [July 28, 2025, 6:32am UTC](https://forum.ansible.com/t/cannot-extract-specific-value-from-imported-task/44145 "2025-07-28T06:32:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hedia](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Hedia](https://forum.ansible.com/u/Hedia)\
**Post date:** [July 28, 2025, 6:32am UTC](https://forum.ansible.com/t/cannot-extract-specific-value-from-imported-task/44145/1 "2025-07-28T06:32:55Z")

</div>

Hi all,

I have an issue to extract specific value from a task imported into a playbook.  
In the task, I use register command (register azure\_key\_vault\_key\_1\_1\_name\_id\_result)

azure\_key\_vault\_key\_1\_1\_name\_id\_result looks like  
ok: [localhost] =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“ad\_user”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“adfs\_authority\_url”: null,  
“api\_profile”: “latest”,  
“auth\_source”: “auto”,  
“cert\_validation\_mode”: null,  
“client\_id”: null,  
“cloud\_environment”: “AzureCloud”,  
“disable\_instance\_discovery”: false,  
“log\_mode”: null,  
“log\_path”: null,  
“name”: “kvk-xxxx-vm-p”,  
“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“profile”: null,  
“secret”: null,  
“show\_deleted\_key”: false,  
“subscription\_id”: “xxxxx-xxxxx-xxxxx-xxxxx-xxxxxx”,  
“tags”: null,  
“tenant”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“thumbprint”: null,  
“vault\_uri”: “[https://kv-xxxxx-p.vault.azure.net/](https://kv-xxxxx-p.vault.azure.net/)”,  
“version”: “current”,  
“x509\_certificate\_path”: null  
}  
},  
“keys”: [  
{  
“attributes”: {  
“created”: “2025-06-11T06:33:31+00:00”,  
“enabled”: true,  
“expires”: null,  
“not\_before”: null,  
“recovery\_level”: “Recoverable”,  
“updated”: “2025-06-11T06:33:31+00:00”  
},  
“key”: {  
“crv”: null,  
“e”: “AQAB”,  
“n”: “xxxx”,  
“y”: null  
},  
“kid”: “[https://kv-xxxx.vault.azure.net/keys/kvk-xxxxx-vm-p/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx](https://kv-xxxx.vault.azure.net/keys/kvk-xxxxx-vm-p/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)”,  
“managed”: null,  
“permitted\_operations”: [  
“sign”,  
“verify”,  
“wrapKey”,  
“unwrapKey”,  
“encrypt”,  
“decrypt”  
],  
“tags”: {},  
“type”: “RSA”,  
“version”: “eda76e152ead409881546fb367422930”  
}  
]  
}

In the current playbook, I try the extract the kid value (last line)

- name: Create Disk Encryption Set “{{ azure\_disk\_encryption\_set\_1\_1\_name\_id }}” in “{{ azure\_resource\_group\_name\_secu\_1\_id }}”  
azure.azcollection.azure\_rm\_diskencryptionset:  
subscription\_id: “{{ azure\_subscription\_id }}”  
ad\_user: “{{ azure\_ad\_user\_id }}”  
password: “{{ azure\_ad\_user\_password\_id }}”  
location: “{{ azure\_location\_1\_id }}”  
resource\_group: “{{ azure\_resource\_group\_name\_secu\_1\_id }}”  
name: “{{ azure\_disk\_encryption\_set\_1\_1\_name\_id }}”  
tenant: “{{ azure\_tenant\_id }}”  
source\_vault: “{{ azure\_key\_vault\_1\_1\_name\_id }}”  
key\_url: “{{ azure\_key\_vault\_key\_1\_1\_name\_id\_result.keys.kid[0].kid }}”

The task failed with the following error message  
fatal: [localhost]: FAILED! =\> {  
“msg”: “The task includes an option with an undefined variable.. ‘builtin\_function\_or\_method object’ has no attribute ‘kid’\n\nThe error appears to be in ‘/hedia/ansible/playbooks/azure/roles/security/tasks/disk-encryption-set.yml’: line 4, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# Disk Encryption Set in Francfort\n- name: Create Disk Encryption Set "{{ azure\_disk\_encryption\_set\_1\_1\_name\_id }}" in "{{ azure\_resource\_group\_name\_secu\_1\_id }}"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with\_items:\n - {{ foo }}\n\nShould be written as:\n\n with\_items:\n - "{{ foo }}"\n”

If I put the value mnually, it works  
key\_url: “[https://kv-xxxx.vault.azure.net/keys/kvk-xxx-vm-f/xxxxxxxxxxxxxxxxx](https://kv-xxxx.vault.azure.net/keys/kvk-xxx-vm-f/xxxxxxxxxxxxxxxxx)”

Any idea ??

Thanks for your help

Regards,

HA

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [July 28, 2025, 6:32pm UTC](https://forum.ansible.com/t/cannot-extract-specific-value-from-imported-task/44145/2 "2025-07-28T18:32:29Z")

</div>

This is a limitation of using dot notation. Some attributes, like `keys`, will be Python dict attrs instead of keys in the dictionary.

There’s a related [FAQ](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#ansible-allows-dot-notation-and-array-notation-for-variables-which-notation-should-i-use), and a [list of reserved keys](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#referencing-key-value-dictionary-variables).

You can use bracket/array notation instead. Untested, but I think you want:

```yaml
- name: Create Disk Encryption Set "{{ azure_disk_encryption_set_1_1_name_id }}" in "{{ azure_resource_group_name_secu_1_id }}"
  azure.azcollection.azure_rm_diskencryptionset:
    subscription_id: "{{ azure_subscription_id }}"
    ad_user: "{{ azure_ad_user_id }}"
    password: "{{ azure_ad_user_password_id }}"
    location: "{{ azure_location_1_id }}"
    resource_group: "{{ azure_resource_group_name_secu_1_id }}"
    name: "{{ azure_disk_encryption_set_1_1_name_id }}"
    tenant: "{{ azure_tenant_id }}"
    source_vault: "{{ azure_key_vault_1_1_name_id }}"
    key_url: "{{ azure_key_vault_key_1_1_name_id_result['keys'][0]['kid'] }}"

```

---

<div class="post-metadata">

**Author:** ![Hedia](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@Hedia](https://forum.ansible.com/u/Hedia)\
**Post date:** [July 29, 2025, 5:36am UTC](https://forum.ansible.com/t/cannot-extract-specific-value-from-imported-task/44145/3 "2025-07-29T05:36:43Z")

</div>

Hi Shertel,

It works fine now !!  
Many thanks for your help !

Regards,

HA

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 28, 2025, 5:37am UTC](https://forum.ansible.com/t/cannot-extract-specific-value-from-imported-task/44145/4 "2025-08-28T05:37:17Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
