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 |
Describe the working of ansible.
How can I set the path or any other environment variable for a task or entire playbook?
What is ansible and what makes it stand out from the rest of the configuration management tools?
Compare ansible vs puppet?
How to create encrypted files using ansible?
Does ansible support aws?
What is ansible galaxy?
When should I use {{ }}? Also, how to interpolate variables or dynamic variable names
Explain what are playbooks in ansible? Explain with some examples.
Where does the configuration file live and what can I configure in it?
Write an ansible playbook to automate the starting of ec2 instance.
Explain in detail about ad-hoc command?