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?



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

Answer / 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

More Ansible Interview Questions

What are ad-hoc commands?

1 Answers  


What is ci/cd?

1 Answers  


How can you create a lamp stack and deploy a webpage by using ansible?

1 Answers  


How ansible works?

1 Answers  


Explain the callback plugin in ansible?

1 Answers  


How do I access shell environment variables?

1 Answers  


How do I disable cowsay?

1 Answers  


Enlist the differences between variable name and environment variables.

1 Answers  


Is there a web interface / rest api / etc?

1 Answers  


What is the ask_pass module in ansible?

1 Answers  


How to create encrypted files using ansible?

1 Answers  


What are ansible vaults?

1 Answers  


Categories