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