http://mithuntechnologies.com/
http://mithuntechnologies.co.in
Ansible Interview Questions
Describe each of the following components in Ansible, including the relationship between them:
Task
Module
Play
Playbook
Role
Ans)
How Ansible is different from other Automation tools?
Ans)
What kind of automation you wouldn't do with Ansible and why?
Ans)
What is an inventory file and how do you define one?
Ans)
Subscribe our YouTube channel for more Free DevOps videos.
https://www.youtube.com/channel/UC-Jr307MbEREy8bG6McwD6w
What is a dynamic inventory file? When you would use one?
Ans)
How do you list all modules and how can you see details on a specific module?
Ans)
Write a task to create the directory ‘/tmp/new_directory’
Ans)
You want to run Ansible playbook only on specific minor version of your OS, how would you achieve that?
Ans)
What the "become" directive used for in Ansible?
Ans)
What are facts? How to see all the facts of a certain host?
Ans)
What would be the result of the following play?
Ans)
Subscribe our YouTube channel for more Free DevOps videos.
https://www.youtube.com/channel/UC-Jr307MbEREy8bG6McwD6w
What would be the result of running the following task? How to fix it?
- hosts: localhost
tasks:
- name: Install zlib
package:
name: zlib
state: present
Ans)
Which Ansible best practices are you familiar with?. Name at least three
Ans)
Explain the directory layout of an Ansible role
Ans)
What 'blocks' are used for in Ansible?
Ans)
How do you handle errors in Ansible?
Ans)
You would like to run a certain command if a task fails. How would you achieve that?
Ans)
Write a playbook to install ‘zlib’ and ‘vim’ on all hosts if the file ‘/tmp/mario’ exists on the system.
Ans)
Write a single task that verifies all the files in files_list variable exist on the host
Ans)
Write a playbook to deploy the file ‘/tmp/system_info’ on all hosts except for controllers group, with the following content
The variable 'whoami' defined in the following places:
role defaults -> whoami: mario
extra vars (variables you pass to Ansible CLI with -e) -> whoami: toad
host facts -> whoami: luigi
inventory variables (doesn’t matter which type) -> whoami: browser
According to variable precedence, which one will be used?
For each of the following statements determine if it's true or false:
A module is a collection of tasks
It’s better to use shell or command instead of a specific module
Host facts override play variables
A role might include the following: vars, meta, and handlers
Dynamic inventory is generated by extracting information from external sources
It’s a best practice to use indention of 2 spaces instead of 4
‘notify’ used to trigger handlers
This “hosts: all:!controllers” means ‘run only on controllers group hosts
Explain the Diffrence between Forks and Serial & Throttle.
Ans)
Subscribe our YouTube channel for more Free DevOps videos.
https://www.youtube.com/channel/UC-Jr307MbEREy8bG6McwD6w
What is ansible-pull? How is it different from how ansible-playbook works?
Ans)
What is Ansible Vault?
Ans)
Demonstrate each of the following with Ansible:
Conditionals
Loops
Ans)
What are filters? Do you have experience with writing filters?
Ans)
Write a filter to capitalize a string
Ans)
You would like to run a task only if previous task changed anything. How would you achieve that?
Ans)
What are callback plugins? What can you achieve by using callback plugins?
Ans)
What is Ansible Collections?
Ans)
File '/tmp/exercise' includes the following content
Goku = 9001
Vegeta = 5200
Trunks = 6000
Gotenks = 32
With one task, switch the content to:
Goku = 9001
Vegeta = 250
Trunks = 40
Gotenks = 32
How do you test your Ansible based projects?
Ans)
What is Molecule? How does it works?
Ans)
You run Ansibe tests and you get "idempotence test failed". What does it mean? Why idempotence is important?
Ans)
Subscribe our YouTube channel for more Free DevOps videos.
https://www.youtube.com/channel/UC-Jr307MbEREy8bG6McwD6w