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 is ansible galaxy?

1 Answers  


How can you speed up management inside in ec2?

1 Answers  


How do I speed up management inside ec2?

1 Answers  


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

1 Answers  


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

1 Answers  


Describe the working of ansible.

1 Answers  


why don’t you ship in x format?

1 Answers  


Suppose you’re using ansible to configure the production environment and your playbook uses an encrypted file. Encrypted files prompt the user to enter passwords. But since ansible is used for automation, can this process be automated?

1 Answers  


How does configuration management is help an organization?

1 Answers  


How to keep secret data in a playbook?

1 Answers  


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

1 Answers  


What are ansible server requirements?

1 Answers  


Categories