# authorized\_key module with delegate\_to

**URL:** <https://forum.ansible.com/t/authorized-key-module-with-delegate-to/21107>\
**Category:** Ansible Project\
**Created:** [April 8, 2016, 11:21am UTC](https://forum.ansible.com/t/authorized-key-module-with-delegate-to/21107 "2016-04-08T11:21:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![deorene](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@deorene](https://forum.ansible.com/u/deorene)\
**Post date:** [April 8, 2016, 11:21am UTC](https://forum.ansible.com/t/authorized-key-module-with-delegate-to/21107/1 "2016-04-08T11:21:29Z")

</div>

Hi,

In my playbook I copy the ssh public key to my local ansible master.

- name: fetch pub key from server  
fetch: src=/home/user/.ssh/id\_rsa.pub dest=/tmp/keys/{{ inventory\_hostname\_short }}\_id\_rsa.pub flat=yes

Next I use authorized\_key module to place it in authorized keys of another user on the server.

- name: ensure public key is authorized\_keys on local host  
authorized\_key: user=user2  
key=“{{ lookup(‘file’, ‘/tmp/keys/{{ inventory\_hostname\_short }}\_id\_rsa.pub’) }}”

The issue I’m having is that the next task is to copy the public key to the authorized keys of the backup server using “delegate\_to”

- name: ensure public key is authorized\_keys on backup server

authorized\_key: user=user2  
key=“{{ lookup(‘file’, ‘/tmp/keys/{{ inventory\_hostname\_short }}\_id\_rsa.pub’) }}”  
delegate\_to: backup\_server

This use to work, but no longer does as it seems to ignore the delegate\_to and copies to authorized to server again.

Using ansible 2.0.1.0

Regards
