LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using ansbile to deploy your ssh keys (https://www.linuxquestions.org/questions/linux-newbie-8/using-ansbile-to-deploy-your-ssh-keys-4175590368/)

soy_vivi 09-28-2016 06:46 PM

Using ansbile to deploy your ssh keys
 
Hello everyone,

I'm attempting to deploy my public ssh key (id_rsa.pub) from one server to two other servers. I'm using the the example here http://docs.ansible.com/ansible/auth...ey_module.html with the following configuration file called sshkeys.yml:

- name: Add Pub key
- hosts: server1,server2
- authorized_key: user=user1 key="{{ lookup('file', '/home/user1/.ssh/id_rsa.pub') }}"

The command I'm running is ansible-playbook sshkeys.yml -u user1 -k and the result I'm getting is this:

"ERROR! 'authorized_key' is not a valid attribute for a Play

The error appears to have been in '/home/user1/playbooks/sshkeys.yml': line 4, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- hosts: server1,server2
- authorized_key: user=user1 key="{{ lookup('file', '/home/user1/.ssh/id_rsa.pub') }}"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:

with_items:
- {{ foo }}

Should be written as:

with_items:
- "{{ foo }}"

I'm copy the authorized_key value directly from ansible's documentation site. I have looked up at other examples but they don't vary from mine. Again, I'm just trying to deploy my public key from another server to two remote servers in the same subnet. Thanks in advance for your input.

arizonagroovejet 10-01-2016 10:49 AM

Take a look at
http://www.linuxquestions.org/questi...or-4175590516/
Are the two of you in the same class or something?

student23 10-01-2016 12:31 PM

Arizonagroovejet, I posted the same question because I thought this didn't post. I will close this one as a duplicate. Do you have any input on the question?


All times are GMT -5. The time now is 01:05 PM.