Top 20 Ansible Interview Questions and Answers

Updated 12 Jul 2025

Asked in TCS

6d ago

Q. What should be defined in the Ansible inventory file?

Ans.

The ansible inventory file defines the hosts and groups that ansible can manage.

  • Hosts and groups are defined using INI or YAML syntax

  • Hosts can have variables defined for them

  • Groups can have child groups and variables defined for them

  • Inventory files c...read more

Asked in TCS

3d ago

Q. How do you use Ansible variables?

Ans.

Ansible variables can be used to store and retrieve values in playbooks and templates.

  • Variables can be defined in inventory files, playbooks, or roles

  • Variables can be accessed using the {{ variable_name }} syntax

  • Variables can be set using the set_fac...read more

Q. What is the command to list all hosts of an Ansible inventory?

Ans.

The command to list all hosts of Ansible inventory is 'ansible-inventory --list'.

  • Use the 'ansible-inventory' command

  • Add the '--list' option to list all hosts

  • The command should be run from the command line

Asked in UKG

4d ago

Q. Write a Terraform and Ansible script.

Ans.

Write Terraform and Ansible script

  • Use Terraform to provision infrastructure resources like virtual machines, networks, and storage

  • Use Ansible to configure and manage software on the provisioned infrastructure

  • Create a Terraform script to deploy a virt...read more

Are these interview questions helpful?

Asked in Infosys

3d ago

Q. Explain modules in Ansible.

Ans.

Ansible modules are reusable, standalone scripts that can be used to automate tasks in Ansible.

  • Modules are the building blocks of Ansible playbooks

  • They can be used to perform specific tasks like installing packages, managing files, or configuring ser...read more

Q. What are the differences between Ansible and Jenkins?
Ans.

Ansible is a configuration management tool, while Jenkins is a continuous integration and continuous deployment tool.

  • Ansible is used for configuration management and automation of tasks, while Jenkins is used for automating the build, test, and deplo...read more

Share interview questions and help millions of jobseekers 🌟
man with laptop
4d ago

Q. How does Ansible handle errors?

Ans.

Error handling in Ansible involves using various modules and strategies to manage and respond to errors during playbook execution.

  • Use the 'failed_when' directive in tasks to specify conditions that should result in a task failure.

  • Utilize the 'ignore_...read more

4d ago

Q. Write an Ansible script.

Ans.

Ansible script to automate tasks

  • Use YAML syntax to define tasks and playbooks

  • Utilize Ansible modules for different operations

  • Define hosts and groups in inventory file

  • Use variables and templates for dynamic configurations

Asked in IBM

2d ago

Q. Explain the Ansible architecture.

Ans.

Ansible architecture is based on a client-server model where the control machine communicates with managed nodes using SSH.

  • Ansible control machine: where playbooks are written and executed

  • Managed nodes: machines that are being managed by Ansible

  • Inven...read more

2d ago

Q. What is the difference between Docker and Ansible?

Ans.

Docker is a containerization platform used to package and run applications, while Ansible is a configuration management tool used for automating IT infrastructure tasks.

  • Docker is used to create containers that encapsulate an application and its depen...read more

Ansible Jobs

Red Hat India Pvt Ltd logo
Senior Software Quality Engineer - Model Inferencing (Pytest, ML Ops) 4-9 years
Red Hat India Pvt Ltd
4.3
Bangalore / Bengaluru
Red Hat India Pvt Ltd logo
Senior Software Engineer - Enterprise Linux Platform 5-10 years
Red Hat India Pvt Ltd
4.3
₹ 18 L/yr - ₹ 31 L/yr
(AmbitionBox estimate)
Bangalore / Bengaluru
Red Hat India Pvt Ltd logo
Senior SRE - IT AI Platforms 3-8 years
Red Hat India Pvt Ltd
4.3
Bangalore / Bengaluru

Asked in TCS

2d ago

Q. Store ansible secrets Trigger pipeline after another

Ans.

Store ansible secrets securely and trigger pipeline after another

  • Use ansible-vault to encrypt sensitive data like passwords and API keys

  • Store encrypted secrets in a separate file or in a secure vault

  • Use ansible-playbook to trigger pipelines sequentia...read more

Asked in Accenture

1d ago

Q. Where do you save Ansible files?

Ans.

Ansible files are typically saved in a version control system like Git for easy access and collaboration.

  • Save ansible files in a version control system like Git

  • Create separate repositories for different projects or roles

  • Organize files into directorie...read more

Q. What packages do we use in Ansible?

Ans.

Some common packages used in Ansible are ansible, ansible-lint, ansible-playbook, ansible-vault, and ansible-doc.

  • ansible

  • ansible-lint

  • ansible-playbook

  • ansible-vault

  • ansible-doc

Asked in Capgemini

6d ago

Q. Explain dynamic inventory in Ansible.

Ans.

Dynamic inventory is a feature in Ansible that allows for automatic inventory updates based on external data sources.

  • Dynamic inventory can be configured to pull inventory information from sources such as cloud providers, configuration management data...read more

Asked in Dell EMC

2d ago

Q. How do you create VMs using Ansible?

Ans.

VMs can be created using ansible by defining the virtual machine specifications in a playbook and running it on the target host.

  • Define the virtual machine specifications in a playbook using the 'virt' module

  • Specify the name, memory, vCPU, disk, netwo...read more

Asked in TCS

6d ago

Q. Write a playbook to copy files in Ansible.

Ans.

Playbook to copy files in Ansible

  • Use the 'copy' module in Ansible to copy files

  • Specify source and destination paths in the playbook

  • Run the playbook using 'ansible-playbook' command

Asked in Katonic

1d ago

Q. How would you install Apache Server using Ansible?

Ans.

To install Apache Server using Ansible, you can create an Ansible playbook with tasks to install Apache and start the service.

  • Create an Ansible playbook with tasks to install Apache Server package (e.g. apache2) using the 'apt' module.

  • Include a task ...read more

Asked in STG Labs

4d ago

Q. How does Ansible work with Windows, and can you explain any relevant scenarios?

Ans.

Ansible works with Windows by using PowerShell remoting and WinRM to manage Windows servers.

  • Ansible uses PowerShell remoting and WinRM to communicate with Windows servers.

  • It can execute PowerShell scripts and commands on Windows servers.

  • Ansible can m...read more

Asked in Ericsson

6d ago

Q. Ansible playbook about upgrading apache

Ans.

An Ansible playbook for upgrading Apache

  • Use the 'yum' module to update the Apache package

  • Restart the Apache service using the 'systemd' module

  • Include error handling in case the update fails

4d ago

Q. Ansible different playbooks

Ans.

Ansible playbooks are YAML files that define a set of tasks to be executed on a target host.

  • Playbooks can be used to install software, configure services, and manage files on remote hosts.

  • Each playbook can contain multiple plays, each targeting a spe...read more

Asked in TCS

1d ago

Q. How do you perform a dry run in Ansible?

Ans.

Dry run in Ansible is a simulation of playbook execution without making any actual changes on the target hosts.

  • Dry run can be performed using the --check flag in ansible-playbook command.

  • It allows the user to see what changes would be made without ac...read more

Asked in Neustar

1d ago

Q. How does variable precedence work in Ansible?

Ans.

Variable precedence in Ansible

  • Ansible follows a specific order to determine variable precedence

  • Highest precedence: Variables defined in playbooks or roles

  • Next: Variables defined in inventory files or inventory plugins

  • Then: Variables defined in comman...read more

Q. Where does the Ansible server maintain the inventory?

Ans.

Ansible server maintains the inventory in a file called 'hosts' by default.

  • Ansible server maintains the inventory in a file called 'hosts' by default

  • The 'hosts' file can be located in the /etc/ansible/ directory or specified using the -i option

  • Invent...read more

Asked in Rebel Foods

6d ago

Q. What are the differences between Terraform and Ansible?

Ans.

Terraform is used for infrastructure provisioning and management, while Ansible is used for configuration management and automation.

  • Terraform is used for defining and managing infrastructure as code, focusing on provisioning resources like virtual ma...read more

Asked in TCS

6d ago

Q. What are the modules in Ansible?

Ans.

Ansible modules are reusable, standalone scripts that can be used to automate tasks in Ansible.

  • Modules are categorized into core modules and extras modules.

  • Core modules are included in the Ansible package, while extras modules are available as separa...read more

Asked in Synechron

5d ago

Q. Ansible terraform usage

Ans.

Ansible and Terraform are tools used for automation and infrastructure management.

  • Ansible is used for configuration management and automation of IT infrastructure.

  • Terraform is used for infrastructure as code and provisioning of resources.

  • Both tools c...read more

1d ago

Q. Modules in Anaible

Ans.

Modules in Ansible are reusable, standalone scripts that can be used to perform specific tasks.

  • Modules can be written in any programming language

  • Modules can be executed on remote hosts

  • Modules can be used to install packages, manage files, and perform...read more

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.7
 • 8.7k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
View all

Interview Questions of Ansible Related Designations

interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
Ansible Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 Lakh+

Reviews

10L+

Interviews

4 Crore+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits