# I can read the key from KV but cannot pass it on as a private key.

**URL:** <https://forum.ansible.com/t/i-can-read-the-key-from-kv-but-cannot-pass-it-on-as-a-private-key/32738>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [April 20, 2020, 3:34pm UTC](https://forum.ansible.com/t/i-can-read-the-key-from-kv-but-cannot-pass-it-on-as-a-private-key/32738 "2020-04-20T15:34:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali\_Shaik](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Ali\_Shaik](https://forum.ansible.com/u/Ali_Shaik)\
**Post date:** [April 20, 2020, 3:34pm UTC](https://forum.ansible.com/t/i-can-read-the-key-from-kv-but-cannot-pass-it-on-as-a-private-key/32738/1 "2020-04-20T15:34:57Z")

</div>

At the time of running the playbook, ansible should be able to source the key from Azure Key Vault and use that key to log in to the hosts.

With managed keys in KV it is possible to capture the key at the run time, but how do I pass that as an **ansible\_ssh\_private\_key**

- hosts: tested1  
tasks:
  - name: Install Apache and PHP  
vars:  
url: ‘[https://demkeyvault.vault.azure.net/](https://demkeyvault.vault.azure.net/)’  
secretname: ‘adminPassword’  
ansible\_ssh\_private\_key: “{{lookup(‘azure\_keyvault\_secret’,secretname,vault\_url=url, client\_id=client\_id, secret=secret, tenant\_id=tenant)}}”  
yum: name=httpd,php state=installed

Ansible version is 2.9
