Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Interview Questions & Answers for Ansible

Table of Contents

Ansible


Describe each of the following components in Ansible, including the relationship between them:

  • Task
  • Module
  • Play
  • Playbook
  • Role

How Ansible is different from other Automation tools?

True or False? Ansible follows the mutable infrastructure paradigm

True or False? Ansible uses declarative style to describe the expected end state

What kind of automation you wouldn’t do with Ansible and why?

What is an inventory file and how do you define one?

What is a dynamic inventory file? When you would use one?

How do you list all modules and how can you see details on a specific module?

Write a task to create the directory ‘/tmp/new_directory’

You want to run Ansible playbook only on specific minor version of your OS, how would you achieve that?

What the “become” directive used for in Ansible?

What are facts? How to see all the facts of a certain host?

What would be the result of the following play?

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

Which Ansible best practices are you familiar with?. Name at least three

Explain the directory layout of an Ansible role

What ‘blocks’ are used for in Ansible?

How do you handle errors in Ansible?

You would like to run a certain command if a task fails. How would you achieve that?

Write a playbook to install ‘zlib’ and ‘vim’ on all hosts if the file ‘/tmp/mario’ exists on the system.

Write a single task that verifies all the files in files_list variable exist on the host

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.

What is ansible-pull? How is it different from how ansible-playbook works?

What is Ansible Vault?

Demonstrate each of the following with Ansible:

  • Conditionals
  • Loops

What are filters? Do you have experience with writing filters?

Write a filter to capitalize a string

You would like to run a task only if previous task changed anything. How would you achieve that?

What are callback plugins? What can you achieve by using callback plugins?

What is Ansible Collections?

Ansible Testing

How do you test your Ansible based projects?

What is Molecule? How does it works?

You run Ansibe tests and you get “idempotence test failed”. What does it mean? Why idempotence is important?

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)