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

What are the different components of ansible?

1 Answers  


Explain the callback plugin in ansible?

1 Answers  


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

1 Answers  


How do I handle different machines needing different user accounts or ports to log in with?

1 Answers  


What is the way to access shell environment variables in ansible?

1 Answers  


When should you test playbooks and roles?

1 Answers  


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

1 Answers  


Why is ‘{{ }}’ notation used?

1 Answers  


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

1 Answers  


Explain different modules in ansible.

1 Answers  


What are the ansible modules?

1 Answers  


What is ansible role and how are they different from the playbook?

1 Answers  


Categories