Ansible Interview Questions and Answers
Related differences
Ques 26. What is the purpose of the 'delegate_to' keyword in Ansible?
The 'delegate_to' keyword is used to run a task on a different host than the one specified in the playbook. It is useful for offloading tasks to specific hosts.
Example:
delegate_to: backup_server
Ques 27. Explain Ansible dynamic variables.
Dynamic variables in Ansible are variables whose values are generated or fetched dynamically during playbook execution. They provide flexibility in configuration.
Ques 28. How can you check if a file or directory exists in Ansible?
The 'stat' module in Ansible can be used to check the existence of a file or directory. The result can be checked using the 'stat.exists' attribute.
Example:
stat:
path: /path/to/file.txt
Ques 29. Explain Ansible Tower Workflows.
Ansible Tower Workflows allow the creation of complex job workflows by combining multiple playbooks and job templates. They provide a visual representation of the workflow.
Ques 30. How can you override variables in Ansible?
Variables in Ansible can be overridden at different levels, including playbooks, inventory files, and the command line. The precedence order determines which value is used.
Example:
ansible-playbook site.yml -e 'variable_name=new_value'
Most helpful rated by users: