Copy files with hostname to respective hosts

Hi,

I have three files,
host1.zip, host2.zip, host3.zip which are in the ansible server itself in a directory named “deploy”.
And I have to copy the files the respective hosts.

host1.zip -----to-----> host1
host2.zip -----to-----> host2
host3.zip -----to-----> host3

I want ansible to look into the directory “deploy”, check the files, match it with the hostnames and copy to the respective hosts.

How do I achieve the same ?

Regards,
Uday

Hello,

host1.zip -----to-----> host1
host2.zip -----to-----> host2
host3.zip -----to-----> host3

I want ansible to look into the directory "deploy", check the files, match
it with the hostnames and copy to the respective hosts.

How do I achieve the same ?

How about a simple copy module usage with the ansible_hostname,
inventory_hostname or ansible_nodename facts?

- name: Copy correct zip file to host
  copy:
    src: "{{ ansible_hostname }}.zip"
    dest: /srv/{{ ansible_hostname }}.zip

http://docs.ansible.com/ansible/latest/modules/copy_module.html

http://docs.ansible.com/ansible/latest/modules/setup_module.html

http://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts

Cheers,
Andy