# How copy directory based on a hostname in a group in ansible?

**URL:** <https://forum.ansible.com/t/how-copy-directory-based-on-a-hostname-in-a-group-in-ansible/24152>\
**Category:** Ansible Project\
**Created:** [April 5, 2017, 9:33pm UTC](https://forum.ansible.com/t/how-copy-directory-based-on-a-hostname-in-a-group-in-ansible/24152 "2017-04-05T21:33:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Siva\_Chowdary](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@Siva\_Chowdary](https://forum.ansible.com/u/Siva_Chowdary)\
**Post date:** [April 5, 2017, 9:33pm UTC](https://forum.ansible.com/t/how-copy-directory-based-on-a-hostname-in-a-group-in-ansible/24152/1 "2017-04-05T21:33:24Z")

</div>

| 

I have 2 hosts in a group:

```auto
[group-1] 
hostname1
hostname2

```

I have 2 directories `hostname1,hostname2` in my local. How can Iconstruct a task to copy `hostname1` directory to host `hostname1`and for `homename2` for a play something like this:

```auto
- name: copy_play
  hosts: group-1
  gather_facts: True
  roles:
    - vlsconfig

```

 |
|
| |
