Discussion:
[ansible-project] authorized_keys not looking in role 'files' directory for files
j***@infinityworks.com
2015-07-23 13:04:36 UTC
Permalink
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

- 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
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bb22d8cf-28e8-4f7f-86cf-3f504adcf362%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Guillaume Querso
2015-07-23 13:18:18 UTC
Permalink
authorized_key seems to look in ./ssh
have you tried to import your file in vars_files?
Post by j***@infinityworks.com
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
- name: Install SSH keys
authorized_key: user=vagrant key="{{ item }}"
- id_rsa.pub
Enter code here...
/-roles
/-- disco
/---- files
/----- id_rsa.pub
/---- tasks
/----- main.yml
/- disco.yml
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
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/71e934bf-1e32-4d32-8b32-1ed593d4057f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
j***@infinityworks.com
2015-07-23 13:32:50 UTC
Permalink
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
Post by Guillaume Querso
authorized_key seems to look in ./ssh
have you tried to import your file in vars_files?
Post by j***@infinityworks.com
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
- name: Install SSH keys
authorized_key: user=vagrant key="{{ item }}"
- id_rsa.pub
Enter code here...
/-roles
/-- disco
/---- files
/----- id_rsa.pub
/---- tasks
/----- main.yml
/- disco.yml
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
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5350c201-1382-4e28-a96d-ebae3483c3b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Guillaume Querso
2015-07-23 13:48:41 UTC
Permalink
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?
Post by j***@infinityworks.com
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
Post by Guillaume Querso
authorized_key seems to look in ./ssh
have you tried to import your file in vars_files?
Post by j***@infinityworks.com
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
- name: Install SSH keys
authorized_key: user=vagrant key="{{ item }}"
- id_rsa.pub
Enter code here...
/-roles
/-- disco
/---- files
/----- id_rsa.pub
/---- tasks
/----- main.yml
/- disco.yml
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
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/199bec8d-f066-4185-87dd-d9ed92c8bc96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...