# authorized\_keys not looking in role 'files' directory for files

**URL:** <https://forum.ansible.com/t/authorized-keys-not-looking-in-role-files-directory-for-files/18831>\
**Category:** Ansible Project\
**Created:** [July 23, 2015, 1:04pm UTC](https://forum.ansible.com/t/authorized-keys-not-looking-in-role-files-directory-for-files/18831 "2015-07-23T13:04:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![james.mcgivern](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@james.mcgivern](https://forum.ansible.com/u/james.mcgivern)\
**Post date:** [July 23, 2015, 1:04pm UTC](https://forum.ansible.com/t/authorized-keys-not-looking-in-role-files-directory-for-files/18831/1 "2015-07-23T13:04:36Z")

</div>

Hi,

I’m trying to add an ssh key to all my servers via the authorized\_keys command but it doesn’t seem to look in the usual places (i.e the role directory(s)). Here’s my code

`

```auto
- name: Install SSH keys
  authorized_key: user=vagrant key="{{ item }}"
  with_file:
    - id_rsa.pub

```

Enter code here…  
`

And my directory structure is:

/-roles  
/-- disco  
/---- files  
/----- id\_rsa.pub  
/---- tasks  
/----- main.yml  
/- disco.yml

And the error on the terminal (with -vvvv):

TASK: [disco | Install SSH keys] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [default] =\> could not locate file in lookup: id\_rsa.pub

FATAL: all hosts have already failed – aborting

It seems that the authorized\_keys does not look in the same folders as ‘copy’, for example.

Thanks  
James

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [July 23, 2015, 1:18pm UTC](https://forum.ansible.com/t/authorized-keys-not-looking-in-role-files-directory-for-files/18831/2 "2015-07-23T13:18:18Z")

</div>

authorized\_key seems to look in ./ssh  
have you tried to import your file in vars\_files?

---

<div class="post-metadata">

**Author:** ![james.mcgivern](https://avatars.discourse-cdn.com/v4/letter/j/8c91f0/32.png) [@james.mcgivern](https://forum.ansible.com/u/james.mcgivern)\
**Post date:** [July 23, 2015, 1:32pm UTC](https://forum.ansible.com/t/authorized-keys-not-looking-in-role-files-directory-for-files/18831/3 "2015-07-23T13:32:50Z")

</div>

Sorry bit of a noob how would this solve the problem? From my understanding authorized\_keys ‘key’ takes either a string (of the key) or a url to the key file. Wouldn’t having it in vars\_file just be specifying the URL in a different place?

Also this means I have to specify this at the host level not the role level which in my current understanding reduces the re-usabiiity.

I’ve seen a couple of bug reports that report similar problems but they all end in “patch merged” and I’m definitely on the latest stable release of ansible…

Thanks

---

<div class="post-metadata">

**Author:** ![Guillaume\_Querso](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Guillaume\_Querso](https://forum.ansible.com/u/Guillaume_Querso)\
**Post date:** [July 23, 2015, 1:48pm UTC](https://forum.ansible.com/t/authorized-keys-not-looking-in-role-files-directory-for-files/18831/4 "2015-07-23T13:48:41Z")

</div>

what i mean is that in your main playbook (the one which trigger the roles) you have the following:  
vars\_files:

- /path/to/your/file

because my understanding of your problem is that you need to access to keys stored as jinja variables in the file right?
