Interview Questions.

Top 100+ Ansible (software) Interview Questions And Answers


Top 100+ Ansible (software) Interview Questions And Answers

Question 1. What Is Ansible?

Answer :

Ansible is a software program device to set up software the usage of ssh with out sny downtime.It is also used to manage and configure software program packages. Ansible is evolved by Python language.

Question 2. What Are The Advantages Of Ansible?

Answer :

Agent-much less
Verylow overhead
Good performance
Python Interview Questions
Question three. How Ansible Works?

Answer :

There are many similar automation gear available like Puppet, Capistrano, Chef, Salt, Space Walk and so forth, but Ansible categorize into  kinds of server: controlling machines and nodes.

The controlling gadget, wherein Ansible is mounted and Nodes are managed by using this controlling device over SSH. The area of nodes are targeted by means of controlling gadget through its inventory.

The controlling machine (Ansible) deploys modules to nodes the use of SSH protocol and these modules are stored quickly on faraway nodes and communicate with the Ansible system through a JSON connection over the same old output.

How Ansible Works:

Ansible is agent-less, which means no need of any agent set up on remote nodes, so it manner there are not any any historical past daemons or packages are executing for Ansible, whilst it’s not managing any nodes.

Ansible can deal with one hundred’s of nodes from a single gadget over SSH connection and the whole operation can be handled and done with the aid of one single command ‘ansible’. But, in some cases, where you required to execute multiple instructions for a deployment, right here we can build playbooks.

Playbooks are bunch of commands that could perform a couple of tasks and every playbooks are in YAML report layout.

Question four. What’s The Use Of Ansible?

Answer :

Ansible may be used in IT infrastructure to manage and install software applications to far off nodes. For example, permit’s say you want to set up a unmarried software or multiple software program to 100’s of nodes via a single command, right here ansible comes into photograph, with the help of Ansible you can deploy as many as programs to many nodes with one single command, however you need to have a bit programming information for understanding the ansible scripts.

We’ve compiled a series on Ansible, name ‘Preparation for the Deployment of your IT Infrastructure with Ansible IT Automation Tool‘, through components 1-4 and covers the following subjects.

Python Tutorial
Question 5. Is There A Web Interface / Rest Api / Etc?

Answer :

Yes, Ansible, Inc makes a high-quality product that makes Ansible even more effective and easy to use. See Ansible Tower.

Web Services Interview Questions
Question 6. How Do I Submit A Change To The Documentation?

Answer :

Documentation for Ansible is stored in the essential challenge git repository, and whole commands for contributing may be discovered in the docs.

Question 7. When Should I Use  ? Also, How To Interpolate Variables Or Dynamic Variable Names?

Answer :

A steadfast rule is ‘constantly use   besides when when:‘. Conditionals are always run through Jinja2 as to clear up the expression, so whilst: failed_when: and changed_when: are always templated and also you need to keep away from adding .

In maximum different instances you ought to always use the brackets, although previouslly you could use variables without specifying (like with_ clauses), as this made it difficult to differentiate among an undefined variable and a string.

Another rule is ‘moustaches don’t stack’. We often see this:


The above DOES NOT WORK, in case you want to use a dynamic variable use the hostvars or vars dictionary as appropriate:

 hostvars[inventory_hostname]['somevar_' + other_var] 

Web Services Tutorial Linux Interview Questions
Question 8. How To Install Ansible?

Answer :

Installation of Ansible Ubuntu 14.04

The quality way to get Ansible for Ubuntu is to feature the project’s PPA (private bundle archive) on your system.

To do that correctly, we want to install the software program-houses-common bundle, for you to provide us the potential to work with PPAs effortlessly. (This package turned into referred to as python-software program-residences on older variations of Ubuntu.)

sudo apt-get update
sudo apt-get set up software-homes-commonplace
Once the package is set up, we can add the Ansible PPA with the aid of typing the following command:

sudo apt-add-repository ppa:ansible/ansible

Press ENTER to accept the PPA addition.

Next, we want to refresh our machine’s bundle index so that it's miles aware about the packages available within the PPA. Afterwards, we are able to set up the software:

sudo apt-get update
sudo apt-get install ansible
We now have all the software required to manage our servers through Ansible.
Question nine. How Do I Generate Crypted Passwords For The User Module?

Answer :

The mkpasswd software that is to be had on maximum Linux structures is a first-rate option:

mkpasswd --technique=sha-512

If this application isn't always mounted on your machine (e.G. You are the usage of OS X) then you could nonetheless without difficulty generate these passwords using Python. First, make certain that the Passlib password hashing library is hooked up.

Pip install passlib

Once the library is ready, SHA512 password values can then be generated as follows:

python -c "from passlib.Hash import sha512_crypt; import getpass; print sha512_crypt.Encrypt(getpass.Getpass())"

Use the incorporated Hashing filters to generate a hashed version of a password. You shouldn’t placed plaintext passwords on your playbook or host_vars; instead, use Vault to encrypt touchy information.

Ruby Interview Questions
Question 10. Desired To Gain Proficiency On Ansible?

Answer :

Explore the weblog put up on Ansible education to come to be a pro in Ansible.

Linux Tutorial
Question eleven. How Do I Get Ansible To Reuse Connections, Enable Kerberized Ssh, Or Have Ansible Pay Attention To My Local Ssh Config File?

Answer :

Switch your default connection kind within the configuration record to ‘ssh’, or use ‘-c ssh’ to use Native OpenSSH for connections instead of the python paramiko library. In Ansible 1.2.1 and later, ‘ssh’ could be used by default if OpenSSH is new sufficient to assist ControlPersist as an alternative.

Paramiko is tremendous for beginning out, however the OpenSSH kind offers many advanced alternatives. You will need to run Ansible from a system new enough to help ControlPersist, if you are using this connection type. You can nevertheless manipulate older clients. If you are using RHEL 6, CentOS 6, SLES 10 or SLES eleven the version of OpenSSH remains a piece vintage, so recall handling from a Fedora or openSUSE client despite the fact that you're managing older nodes, or simply use paramiko.

We hold paramiko as the default as if you are first putting in Ansible on an EL box, it gives a higher revel in for brand new customers.

Docker (software) Interview Questions
Question 12. What Is The Best Way To Make Content Reusable/redistributable?

Answer :

If you have not executed so already, read all about “Roles” in the playbooks documentation. This helps you make playbook content material self-contained, and works properly with things like git submodules for sharing content material with others.

If some of these plugin types look strange to you, see the API documentation for more details about ways Ansible may be extended.

Python Interview Questions
Question thirteen. How Do I See All The Inventory Vars Defined For My Host?

Answer :

You can see the resulting vars you define in inventory walking the subsequent command:

ansible -m debug -a "var=hostvars['hostname']" localhost.

Docker (software program) Tutorial
Question 14. How Do I Copy Files Recursively Onto A Target Host?

Answer :

The “reproduction” module has a recursive parameter, though if you need to do some thing more green for lots files, have a look at the “synchronize” module alternatively, which wraps rsync. See the module index for info on both modules.

Question 15. What Is Ansible Role?

Answer :

Ansible can have interaction with configured customers from the command line with the ansible command, and how you may automate configuration with playbooks run thru the ansible-playbook command.

The first step in growing a role is growing its directory structure. To create the base listing shape, we’re going to use a tool bundled with Ansible known as ansible-galaxy:

$ ansible-galaxy init azavea.Packer
azavea.Packer turned into created effectively
That command will create an azavea.Packer directory with the subsequent shape:


+-- defaults

¦ +-- fundamental.Yml

+-- files

+-- handlers

¦ +-- principal.Yml

+-- meta

¦ +-- essential.Yml

+-- responsibilities

¦ +-- important.Yml

+-- templates

+-- vars

+-- major.Yml

OpenStack Interview Questions
Question 16. How Do I Access A Variable Name Programmatically?

Answer :

An example may additionally arise where we need to get the ipv4 deal with of an arbitrary interface, where the interface to be used may be supplied via a function parameter or different enter. Variable names can be constructed by using adding strings collectively, like so:

 hostvars[inventory_hostname]['ansible_' + which_interface]['ipv4']['address'] 

The trick about going through hostvars is important because it’s a dictionary of the entire namespace of variables. ‘inventory_hostname’ is a magic variable that indicates the contemporary host you are looping over in the host loop.

Jenkins Tutorial
Question 17. How Do I Access Shell Environment Variables?

Answer :

If you simply want to get right of entry to existing variables, use the ‘env’ research plugin.

For instance, to get entry to the price of the HOME surroundings variable on control device:


# ...


   local_home: " research('env','HOME') "

If you want to set environment variables, see the Advanced Playbooks phase approximately environments.

Ansible 1.Four will even make remote environment variables available thru facts within the ‘ansible_env’ variable:


Jenkins Interview Questions