It's this part:

    - name: Copy ths ssh public key into the authorized key dir on the
remote host
        copy
src: "/home/{{item}}/.ssh/id_rsa.pub"

are the public keys at those paths on the Ansible host?

On 8 July 2017 at 19:18, Anfield <[email protected]> wrote:
>
> I have the below playbook. Created ssh keys for dave on the localhost
> (ansible master) and trying to create some users, groups and copy over ssh
> keys for some users all in the playbook.
>
> All works well until the copying over ssh keys part. Ive confirmed the
> directory and public key exists for dave on the localhost..and the playbook
> created /home/dave/.ssh on the remote host
>
> Not sure why this would fail?
>
> Playbook output -
> TASK [Copy ths ssh public key into the authorized key dir on the remote
> host] ********
> failed: [10.10.0.5 -> localhost] (item=frank) => {"failed": true, "item":
> "frank", "ms        g": "Unable to find '/home/frank/.ssh/id_rsa.pub' in
> expected paths."}
> failed: [10.10.0.5 -> localhost] (item=joe) => {"failed": true, "item":
> "joe", "msg":         "Unable to find '/home/joe/.ssh/id_rsa.pub' in
> expected paths."}
> ...ignoring
> failed: [10.10.0.5 -> localhost] (item=dave) => {"failed": true, "item":
> "dave", "msg"        : "Unable to find '/home/dave/.ssh/id_rsa.pub' in
> expected paths."}
>
> Playbook -
> [ansible@localhost playbooks]$ vi userscreate.yml
>  - hosts: 10.10.0.5
>   become: yes
>   vars:
>      grouplist:
>         - devops
>         - dbadbmins
>         - serveradmins
>
>      users:
>         - frank
>         - joe
>         - dave
>
>   tasks:
>     - name: Create groups
>       group:
>         name: "{{ item }}"
>         state: present
>       with_items: "{{grouplist}}"
>       ignore_errors: yes
>
>     - name: Create users
>       user:
>         name: "{{ item }}"
>         state: present
>       with_items: "{{users}}"
>
>     - name: create the users .ssh directories
>       file:
>         path: "/home/{{item}}/.ssh"
>         state: directory
>         owner: "{{item}}"
>         group: "{{item}}"
>       register: user_dirs
>       with_items: "{{users}}"
>
>     - name: Copy ths ssh public key into the authorized key dir on the
> remote host
>         copy
> src: "/home/{{item}}/.ssh/id_rsa.pub"
> dest: "/home/{{item}}/.ssh/authorized_keys"
> owner: "{{item}}"
> group: "{{item}}"
>       with_items: "{{users}}"
>       ignore_errors: true
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/520fbfe4-625e-4f36-96f7-06d5d26a8007%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAK5eLPTQ5pjQj%3DuiC%2Bq8xqzbJgUKE7ueaeMkqs0eC3h92zBwAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to