Ansible Interview Questions and Answers

Q1 : What is Ansible?
A : Ansible is developed in Python language.
It is a software tool. It is useful while deploying any application using ssh without any downtime. Using this tool one can manage and configure software applications very easily.

Q2 : What are the advantages of using Ansible?
A : The main three advantages of using this tool is,i.e. Ansible

  1. Agentless
  2. Very low overhead
  3. Good performance

Q3 : What’s the Use of Ansible?
A : Ansible can be used in IT infrastructure to manage and deploy software applications to remote nodes. For example, let’s say you need to deploy a single software or multiple software to 100’s of nodes by a single command, here ansible comes into picture, with the help of Ansible you can deploy as many as applications to many nodes with one single command, but you must have a little programming knowledge for understanding the ansible scripts.

Q4 : How to install Ansible
A : Installation of Ansible Ubuntu 14.04
The best way to get Ansible for Ubuntu is to add the project’s PPA (personal package archive) to your system.
To do this effectively, we need to install the software-properties-common package, which will give us the ability to work with PPAs easily. (This package was called python-software-properties on older versions of Ubuntu.)

sudo apt-get update
sudo apt-get install software-properties-common

Once the package is installed, we can add the Ansible PPA by typing the following command:

sudo apt-add-repository ppa:ansible/ansible

For the PPA addition, press enter.
After that we can refresh our system package, we can see available PPA packages and can install the software.
sudo apt-get install ansible
sudo apt-get update
Through Ansible, we have the software required to administer our servers.

Q5 : How Ansible Works?
A : There are many similar automation tools available like Puppet, Capistrano, Chef, Salt, Space Walk etc, but Ansible categorize into two types of server: controlling machines and nodes.
The controlling machine, where Ansible is installed and Nodes are managed by this controlling machine over SSH. The location of nodes are specified by controlling machine through its inventory.
The controlling machine (Ansible) deploys modules to nodes using SSH protocol and these modules are stored temporarily on remote nodes and communicate with the Ansible machine through a JSON connection over the standard output.
Ansible is agent-less, that means no need of any agent installation on remote nodes, so it means there are no any background daemons or programs are executing for Ansible, when it’s not managing any nodes.
Ansible can handle 100’s of nodes from a single system over SSH connection and the entire operation can be handled and executed by one single command ‘ansible’. But, in some cases, where you required to execute multiple commands for a deployment, here we can build playbooks.
Playbooks are bunch of commands which can perform multiple tasks and each playbooks are in YAML file format.

Q6 : How do I submit a change to the documentation?
A : Documentation for Ansible is kept in the main project git repository, and complete instructions for contributing can be found in the docs.

Q7 : Mention the best ways to make content redistributable/reusable?
A : Ansible playbook’s files can be reused in three distinct ways: include roles, and imports.
Imports and Include are helpful to create/break up multiple small files of a massive playbook. Roles are primarily used to manage various tasks in a package including handlers, variables, plug-in and other modules. They can also be uploaded and shared by Ansible Galaxy.

Q8 : Is there a web interface / REST API / etc?
A : Yes, Ansible, Inc makes a great product that makes Ansible even more powerful and easy to use.

Q9 : How do I copy files recursively onto a target host?
A : The “copy” module has a recursive parameter, though if you want to do something more efficient for many files, look at the “synchronize” module instead, which wraps rsync. See the module index for info on both modules.

Q10 : Why are you attracted to science and science fiction?
A : Early imprinting, maybe, for the science fiction. When I was quite small a family friend let me read his 1950s run of ‘Galaxy’ magazine. My favourite aunt pressed John Wyndham’s ‘The Day of the Triffids’ on me; a more terrifying great-aunt gave me G.K. Chesterton’s fantastic novels; and so on.
The incurable addiction had begun. Meanwhile, science classes just seemed to be the part of school that made most sense, and I fell in love with Pelican pop-maths titles – especially Kasner’s and Newman’s ‘Mathematics and the Imagination’ and all those books of Martin Gardner’s ‘Scientific American’ columns.

Q11 : So how does Ansible work? Please explain in detail?
A : Within the market, they are many automation tools like Puppet, Capistrano, Chef, Salt, Space Walk etc.

When it comes to Ansible, this tool is categorized into two types of servers:
1. Controlling machines
2. Nodes

Ansible is an agentless tool so it doesn’t require any mandatory installations on remote nodes. So there is no background programs that are executed while it is managing any nodes.
Ansible is able to handle a lot of nodes from a single system over SSH connection.
Playbooks are defined as a bunch of commands where they are capable of performing multiple tasks and they are in YAML file format.

Q12 : What is Ansible Tower?
A : Ansible is classified as a web-based solution which makes Ansible very easy to use. It is considered to be or acts like a hub for all of your automation tasks. The tower is free for usage till 10 nodes.

Q13 : How can you speed up management inside in EC2?
A : It is not advised to manage a group of EC2 machines from your laptop.
The best way is to connect to a management node inside Ec2 first and then execute Ansible from there.

Q14 : What is that Ansible can do?
A : Ansible can do the following for us:
1. Configuration management
2. Application deployment
3. Task automation
4. IT orchestration

Q15 : Do you know what language Ansible is written in?
A : Ansible is written in Python and PowerShell

Q16 : Is Ansible is an open source tool?
A : Yes, Ansible is an open source tool which is a powerful automation software tool that one can use.

Q17 : What are Ansible server requirements?
A : If you are a windows user then you need to have a virtual machine in which Linux should be installed.
It requires Python 2.6 version and higher.

Q18 : What is Ansible Galaxy?
A : Ansible Galaxy refers to the website Galaxy where the users will be able to share all the roles to a CLI ( Command Line interface) where the installation, creation, and managing of roles happen.

Q19 : What is Red Hat Ansible?
A : Ansible and Ansible Tower by Red Hat, both are an end to end complete automation platforms which are capable of providing the following features or functionalities:
1. Provisioning
2. Deploying applications
3. Orchestrating workflows
4. Manage IT systems
5. Configuration of IT systems
6. Networks
7. Applications
All of these activities are dealt by Ansible where it can help the business to solve the real time business problems.

Q20 : Can you build your own modules with Ansible?
A : Yes, we can create or own modules within Ansible.
It is an open source tool which primarily works on Python. If you are good at programming in Python you can start creating your own modules in few hours from scratch and you don’t need to have any prior knowledge of the same.

Q21 : Explain Module utilities in Ansible?
A : Ansible provides a wide variety of module utilities which help the developers while developing their own modules. The basic.py is a module which provides the main entry point for accessing the Ansible library and using those as basics one can start off working.

Q22 : Where is the unit testing is available in Ansible?
A : Unit tests for all the modules are available in .test/units/modules.
Firstly you have to setup your testing environment

Q23 : Explain Callback_plugin in Ansible?
A : Callbacks are explained as a piece of code in ansible environments where get is used call a specific event and permit the notifications.
This is more sort of a developer related feature and allows low-level extensions around ansible so that they can be loaded from different locations without any problem.

 Q24 : How can you find information in Ansible?
A : After completing the basic setup, one has to make sure to find out the module called “setup” module. Using this setup module, you will be able to find out a lot of information.

Q25 : How do change the documentation and submit it?
A : Usually, the documentation is kept in the main project folder in the git repository.
For complete instructions on this can be available in docs.