Top 20 Ansible Interview Questions and Answers
Updated 12 Jul 2025

Asked in TCS

Q. What should be defined in the Ansible inventory file?
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

Q. How do you use Ansible variables?
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

Asked in Broadridge Financial Solutions

Q. What is the command to list all hosts of an Ansible inventory?
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

Q. Write a Terraform and Ansible script.
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

Asked in Infosys

Q. Explain modules in Ansible.
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

Asked in Sourcefuse Technologies

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

Asked in Tech Mahindra

Q. How does Ansible handle errors?
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

Asked in Market Simplified

Q. Write an Ansible script.
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

Q. Explain the Ansible architecture.
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

Asked in Social Prachar

Q. What is the difference between Docker and Ansible?
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




Asked in TCS

Q. Store ansible secrets Trigger pipeline after another
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

Q. Where do you save Ansible files?
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

Asked in Expeditors International

Q. What packages do we use in Ansible?
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

Q. Explain dynamic inventory in Ansible.
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

Q. How do you create VMs using Ansible?
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

Q. Write a playbook to copy files in Ansible.
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

Q. How would you install Apache Server using Ansible?
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

Q. How does Ansible work with Windows, and can you explain any relevant scenarios?
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

Q. Ansible playbook about upgrading apache
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
Asked in Aga IT Solutions

Q. Ansible different playbooks
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

Q. How do you perform a dry run in Ansible?
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

Q. How does variable precedence work in Ansible?
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
Asked in Lemtom Software Systems

Q. Where does the Ansible server maintain the inventory?
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

Q. What are the differences between Terraform and Ansible?
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

Q. What are the modules in Ansible?
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

Q. Ansible terraform usage
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

Asked in Morgan Stanley

Q. Modules in Anaible
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
Top Interview Questions for Related Skills
Interview Experiences of Popular Companies





Interview Questions of Ansible Related Designations



Reviews
Interviews
Salaries
Users

