Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can looping be done over a list of hosts in a group, inside of a template?

Answer Posted / Shakher Chaudhary

To loop through a list of hosts in a group and use them in a template with Ansible, you can utilize the `loop` construct. Here is an example:nn```yamln- name: Run a playbook on multiple hostsn hosts: all_serversn tasks:n - name: Render a template on each hostn template: src=myfile.j2 dest=/etc/myfile.confn loop: itemsn vars:n my_variable: "{{ item }}"n delegate_to: {{ item }}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to generate crypto passwords for the user module?

1


How can one generate encrypted passwords for the user module?

2


Compare ansible with chef.

1


What is the difference between a variable name and an environment variable?

1


How do I set the path or any other environment variable for a task?

3


How do I see a list of all of the ansible_ variables?

2


Can you write a simple playbook to install nginx on a host machine?

2


Where does the configuration file live and what can I configure in it?

1


Is ansible an open source tool?

2


Explain a few of the basic terminologies or concepts in ansible.

2


How can looping be done over a list of hosts in a group, inside of a template?

3


How ansible different from the playbook?

1


What is ansible?

1


How can you speed up management inside in ec2?

2


Explain the callback plugin in ansible?

1