# Needs to Write a Playbook

**URL:** <https://forum.ansible.com/t/needs-to-write-a-playbook/33179>\
**Category:** Ansible Project\
**Created:** [June 15, 2020, 6:26am UTC](https://forum.ansible.com/t/needs-to-write-a-playbook/33179 "2020-06-15T06:26:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rama543](https://avatars.discourse-cdn.com/v4/letter/r/50afbb/32.png) [@rama543](https://forum.ansible.com/u/rama543)\
**Post date:** [June 15, 2020, 6:26am UTC](https://forum.ansible.com/t/needs-to-write-a-playbook/33179/1 "2020-06-15T06:26:48Z")

</div>

Hi Friends,

I am new to this Ansible world

Needs to write a playbook for one scenario

Scenario-1:

I have 1000 Servers . Host-names are like Server1, Server2, Server3, Server4, Server5, …Server1000 .

I have two Script files Script-1.sh and Script-2.sh in my controller .

Now i want create a folder “/opt/Server/Odd” and copy the Script-1.sh file in Server1, Server3, Server5, Server7 …Server999 .  
create a folder “/opt/Server/Even” and copy the Script-2.sh file in Server2, Server4, Server6, Server8, …Server1000.

Can you guys help me to write playbook

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [June 15, 2020, 7:06am UTC](https://forum.ansible.com/t/needs-to-write-a-playbook/33179/2 "2020-06-15T07:06:45Z")

</div>

Hi Rama,

What have you tried and what is error that you are getting?

---

<div class="post-metadata">

**Author:** ![Rafael\_Tomelin](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Rafael\_Tomelin](https://forum.ansible.com/u/Rafael_Tomelin)\
**Post date:** [June 17, 2020, 11:08am UTC](https://forum.ansible.com/t/needs-to-write-a-playbook/33179/3 "2020-06-17T11:08:11Z")

</div>

Hi Rama,

You can create playbook/role simples:

1. create regex and split server from number “{{ ansible\_hostname.split(‘server’)[1] }}”
2. Check if the number is divisor per 2; {{ variable\_number % 2 }}
3. if divisor 2, copy script1 else copy script 2 file: src: script{{ var01 }}
