# Specifying the private key file in a playbook

**URL:** <https://forum.ansible.com/t/specifying-the-private-key-file-in-a-playbook/14489>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [February 4, 2014, 7:54pm UTC](https://forum.ansible.com/t/specifying-the-private-key-file-in-a-playbook/14489 "2014-02-04T19:54:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [February 4, 2014, 7:54pm UTC](https://forum.ansible.com/t/specifying-the-private-key-file-in-a-playbook/14489/1 "2014-02-04T19:54:49Z")

</div>

Hello all,

I’m trying to do this, conceptually:

# this playbook might create the public ssh key file  
- hosts: 127.0.0.1  
&nbsp;&nbsp;connection: local  
&nbsp;&nbsp;[…]

- hosts: base\_instance  
&nbsp;&nbsp;connection: ssh  
&nbsp;&nbsp;remote\_user: ubuntu  
&nbsp;&nbsp;# errors, since private\_key\_file isn’t a real play key.  
&nbsp;&nbsp;private\_key\_file: "{{ environment\_public\_ssh\_key\_file }}"

The idea being that the key file may be created as part of a previous play in the playbook.

Any suggestions are welcome.

-scott---
