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 to interpolate variables or dynamic variable names?



How to interpolate variables or dynamic variable names?..

Answer / Sumit Khari

In Ansible, you can use the 'with_items' and 'set_fact' constructs to iterate over a list of variables and set dynamic variable names. For example: - name: Create vars for hosts with specific facts with_items: "{{ ansible_facts['hostvars']['localhost']['ansible_os_family'] }}" tasks: - set_fact: os_name: "{{ item }}" when: ansible_os_family == item

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Ansible Interview Questions

Describe the working of ansible.

1 Answers  


How can I set the path or any other environment variable for a task or entire playbook?

1 Answers  


What is ansible and what makes it stand out from the rest of the configuration management tools?

1 Answers  


Compare ansible vs puppet?

1 Answers  


How to create encrypted files using ansible?

1 Answers  


Does ansible support aws?

1 Answers  


What is ansible galaxy?

1 Answers  


When should I use {{ }}? Also, how to interpolate variables or dynamic variable names

1 Answers  


Explain what are playbooks in ansible? Explain with some examples.

1 Answers  


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

1 Answers  


Write an ansible playbook to automate the starting of ec2 instance.

1 Answers  


Explain in detail about ad-hoc command?

1 Answers  


Categories