# delegate\_to from inventory? copy between remote hosts

**URL:** <https://forum.ansible.com/t/delegate-to-from-inventory-copy-between-remote-hosts/18914>\
**Category:** Ansible Project\
**Created:** [August 1, 2015, 6:01am UTC](https://forum.ansible.com/t/delegate-to-from-inventory-copy-between-remote-hosts/18914 "2015-08-01T06:01:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixel\_fairy](https://avatars.discourse-cdn.com/v4/letter/p/6f9a4e/32.png) [@pixel\_fairy](https://forum.ansible.com/u/pixel_fairy)\
**Post date:** [August 1, 2015, 6:01am UTC](https://forum.ansible.com/t/delegate-to-from-inventory-copy-between-remote-hosts/18914/1 "2015-08-01T06:01:33Z")

</div>

making a playbook to set up ceph clients, so want to transfer a client key from server (a monitor host) to client. since the server and client are both far away and sitting next to each other, id like to copy between them, so of course, i tried

- name: make sure the client key is in place  
copy: src=/etc/ceph/ceph.client.admin.keyring dest=/etc/pve/priv/ceph/rbd.keyring  
delegate\_to: mons[0]

and to make sure it knew what i wanted,

$ ansible mons[0] --list-hosts  
c1

ran the playbook and got this,

failed: [proxbox → mons[0]] =\> {“failed”: true}  
msg: could not find src=/etc/ceph/ceph.client.admin.keyring

(maybe it was looking on the local filesystem?)

then i tried synchronize, as suggested here, [http://stackoverflow.com/questions/25505146/how-to-copy-files-between-two-nodes-using-ansible](http://stackoverflow.com/questions/25505146/how-to-copy-files-between-two-nodes-using-ansible)  
but got this,

fatal: [proxbox → mons[0]] =\> SSH Error: ssh: Could not resolve hostname mons[0]: nodename nor servname provided, or not known

does delegate\_to not use the inventory?

---

<div class="post-metadata">

**Author:** ![Timothy\_Appnel1](https://avatars.discourse-cdn.com/v4/letter/t/278dde/32.png) [@Timothy\_Appnel1](https://forum.ansible.com/u/Timothy_Appnel1)\
**Post date:** [August 3, 2015, 3:46pm UTC](https://forum.ansible.com/t/delegate-to-from-inventory-copy-between-remote-hosts/18914/2 "2015-08-03T15:46:03Z")

</div>

Try wrapping your mons variable in {{ }} like this…

> delegate\_to: {{ mons[0] }}

I’m pretty sure without them your variable is being interpreted as a literal.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 3, 2015, 4:45pm UTC](https://forum.ansible.com/t/delegate-to-from-inventory-copy-between-remote-hosts/18914/3 "2015-08-03T16:45:56Z")

</div>

quote it

delegate\_to: "{{ mons[0] }}"

---

<div class="post-metadata">

**Author:** ![Timothy\_Appnel1](https://avatars.discourse-cdn.com/v4/letter/t/278dde/32.png) [@Timothy\_Appnel1](https://forum.ansible.com/u/Timothy_Appnel1)\
**Post date:** [August 3, 2015, 7:32pm UTC](https://forum.ansible.com/t/delegate-to-from-inventory-copy-between-remote-hosts/18914/4 "2015-08-03T19:32:47Z")

</div>

Right. Thanks bcoca. Always forget that one until I run.
