Needs to Write a Playbook

28 views
Skip to first unread message

rama543

unread,
Jun 15, 2020, 2:26:48 AM6/15/20
to Ansible Project
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

Abhijeet Kasurde

unread,
Jun 15, 2020, 3:07:22 AM6/15/20
to ansible...@googlegroups.com
Hi Rama,

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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/682613d9-09c4-4aa6-b52e-338a076c51e2o%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde

Rafael Tomelin

unread,
Jun 17, 2020, 7:08:45 AM6/17/20
to ansible...@googlegroups.com
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 }}

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/682613d9-09c4-4aa6-b52e-338a076c51e2o%40googlegroups.com.


--
Atenciosamente,

Rafael Tomelin
Tel.: 51-984104084
Skype: rafael.tomelin

LPI ID: LPI000191271
Red Hat Certified Engineer
Puppet Professional 2017 Certification
Reply all
Reply to author
Forward
0 new messages