Ansible Interview Questions for Experienced/Ansible Interview Questions and Answers for Freshers & Experienced

Explain Callback_plugin in Ansible?

Callbacks are explained as a piece of code in ansible environments where to get is used to 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.

Posted Date:- 2021-11-17 08:57:53

Can you build your own modules with Ansible?

Yes, we can create or own modules within Ansible.

It is an open-source tool that 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.

Posted Date:- 2021-11-17 08:56:52

Why you have to learn Ansible?

Ansible is more a tool for servers but does it have anything for networking. If you closely look into it, there is some support available in the market for networking devices. Using this tool, it will give you an overall view of your environment and also knowledge of how it works when it comes to network automation.

It is one of those tools where it is considered to be good to explore a new tool.

Posted Date:- 2021-11-17 08:55:31

Is Ansible is an open-source tool?

Yes, Ansible is an open-source tool that is a powerful automation software tool that one can use.

Posted Date:- 2021-11-17 08:54:29

Do you know what language Ansible is written in?

Ansible is written in Python and PowerShell

Posted Date:- 2021-11-17 08:53:46

Can you explain how to handle various machines requiring different user accounts or ports to log in?

Just by setting inventories in the inventory file, we can handle various machines requiring different user accounts or ports to log in.

For example, the following hosts have different ports and usernames:

[webservers]
asdf.example.com ansible_port=5000 ansible_user=alice
jkl.example.com ansible_port=5001 ansible_user=bob


You can specify the connection type to be used by:

[testcluster]
localhost ansible_connection=local
/path/to/chroot1 ansible_connection=chroot
foo.example.com ansible_connection=paramiko
File them in a group_vars/<group-name> file.

Posted Date:- 2021-11-17 08:52:53

Why don’t you ship in X format?

They are several reasons for not shipping in X format. In general, it caters to maintainability. Within the market, they are tons of different ways to ship software and it is very tedious to support all of them.

Posted Date:- 2021-11-17 08:51:46

Explain the Ansible Tag's usage?

A tag is an attribute that sets the ansible structure(plays, tasks, roles). When there's an extensive playbook needed, it's more useful to run just a part of it as opposed to the entire thing. That's where tags usage is required.

Posted Date:- 2021-11-17 08:51:04

How will you get access to the ansible host when I delegate a task?

We can access it through host variables and even works for all the overridden variables like ansible_port, ansible_user, etc.

original_host: "{{ hostvars[inventory_hostname]['ansible_host'] }}"

Posted Date:- 2021-11-17 08:50:18

What is the difference between a playbook and a play?

A playbook is a list of plays. A play is a set of tasks and roles that run on one or more managed hosts. Play includes one or more tasks.

Posted Date:- 2021-11-17 08:49:41

Why do we get an error SSL CERTIFICATE_VERIFY_FAILED in Windows under Ansible?

When the Ansible controller is running on Python 2.7.9+ or an older version of Python that has backported SSLContext (like Python 2.7.5 on RHEL 7), the controller will attempt to validate the certificate WinRM is using for an HTTPS connection. If the certificate cannot be validated (such as in the case of a self-signed cert), it will fail the verification process.

To ignore certificate validation, add ansible_winrm_server_cert_validation: ignore to inventory for the Windows host.

Posted Date:- 2021-11-17 08:48:53

Can you create encrypted files with Ansible?

Yes, using the 'ansible-vault create' command, we can create encrypted files

$ ansible-vault create filename.yaml

Posted Date:- 2021-11-17 08:48:09

What is idempotency?

Idempotence is an essential feature of Ansible, which helps you to execute one or more tasks on a server as many times as needed, but without changing the result beyond the initial application.

Posted Date:- 2021-11-17 08:47:21

How Ansible manages multiple communication protocols?

nodes, they can support multiple communication protocols. The communication protocol (XML over SSH, CLI over SSH, API over HTTPS) selected for each network module depends on the platform and the purpose of the module. Some network modules support only one protocol; some offer a choice. The most common protocol is CLI over SSH.

Posted Date:- 2021-11-17 08:46:07

Why Fact Caching is Useful under Ansible?

With fact caching enabled, it is possible for the machine in one group to reference variables about machines in the other group, despite the fact that they have not been communicated within the current execution of /usr/bin/ansible-playbook.

To benefit from cached facts, you will want to change the gathering setting to smart or explicit or set gather_facts to False in most plays.

Currently, Ansible ships with two persistent cache plugins: redis and jsonfile.

To configure fact caching using redis, enable it in ansible.cfg as follows:

[defaults]
gathering = smart
fact_caching = redis
fact_caching_timeout = 86400
# seconds

Posted Date:- 2021-11-17 08:45:28

List few Non-SSH connection types and how to specify them under Ansible?

Ansible executes playbooks over SSH but it is not limited to this connection type. With the host-specific parameter ansible_connection=<connector>, the connection type can be changed. The following non-SSH based connectors are available:

local
This connector can be used to deploy the playbook to the control machine itself.

docker
This connector deploys the playbook directly into Docker containers using the local Docker client.

Posted Date:- 2021-11-17 08:44:36

What is Cache Plugins in Ansible? Any idea how are they enabled?

Cache plugin implements a backend caching mechanism that allows Ansible to store gathered facts or inventory source data without the performance hit of retrieving them from source.
The default cache plugin is the memory plugin, which only caches the data for the current execution of Ansible. Other plugins with persistent storage are available to allow caching the data across runs.

Enabling Cache Plugins
Only one cache plugin can be active at a time. You can enable a cache plugin in the Ansible configuration, either via an environment variable:

export ANSIBLE_CACHE_PLUGIN=jsonfile
or in the ansible.cfg file:

[defaults]
fact_caching=redis

You will also need to configure other settings specific to each plugin. Consult the individual plugin documentation or the Ansible configuration for more details.

Posted Date:- 2021-11-17 08:44:00

Compare Ansible vs Chef

* Ansible is easier to setup than Chef
* Network Management more easy to using Ansible
* In Terms of scalability, both are highly scalable
* For 'Ansible YAML' + Python and for 'DSL + Ruby' is used as a configuration language
* Costing of Ansible in production is cheaper than Puppet.
* Ansible is agentless but Chef needs a customs agent on the remote nodes.

Posted Date:- 2021-11-17 08:43:17

How variables are merged in Ansible?

By default, variables are merged/flattened to the specific host before a play is run.This keeps Ansible focused on the Host and Task, so groups don’t really survive outside of inventory and host matching. By default, Ansible overwrites variables including the ones defined for a group and/or host (see the hash_merge setting to change this). The order/precedence is (from lowest to highest):

* all group (because it is the ‘parent’ of all other groups)
* parent group
* child group
* host

When groups of the same parent/child level are merged, it is done alphabetically, and the last group loaded overwrites the previous groups. For example, an a_group will be merged with b_group and b_group vars that match will overwrite the ones in a_group.

Posted Date:- 2021-11-17 08:41:48

Do you have any idea on how to turn off the facts in Ansible?

If you know you don’t need any factual data about your hosts and know everything about your systems centrally, you can turn off fact gathering. This has advantages in scaling Ansible in push mode with very large numbers of systems, mainly, or if you are using Ansible on experimental platforms.
In any play, just do this:

- hosts: whatever
gather_facts: no

Posted Date:- 2021-11-17 08:40:32

Can I deploy a virtual machine on a standalone ESXi server ?

Yes. vmware_guest can deploy a virtual machine with required settings on a standalone ESXi server.

Posted Date:- 2021-11-17 08:39:44

Have you heard about Ansible-Doc?

Yes. Ansible-Doc displays information on modules installed in Ansible libraries. It displays a terse listing of plugins and their short descriptions, provides a printout of their DOCUMENTATION strings, and it can create a short “snippet” which can be pasted into a playbook.

Posted Date:- 2021-11-17 08:39:13

How to configure a jump host for accessing servers that have no direct access?

We should set a ProxyCommand in the ansible_ssh_common_args inventory variable. For connecting to the relevant host, arguments defined in this variable are added to scp/ssh/sftp command line.

For example,

[gatewayed]
foo ansible_host=192.0.2.1
bar ansible_host=192.0.2.2
With the following contents, create the group_vars/gatewayed.yml

ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q user@gateway.example.com"'
When connecting to any hosts in the group gatewayed, Ansible will append these arguments to the command line.

Posted Date:- 2021-11-17 08:38:07

Which protocols does ansible use to communicate with Linux & Windows?

For Linux , the protocol used is SSH

For Windows, Protocol used in WinRM

Posted Date:- 2021-11-17 08:37:11

Does Ansible support Solaris?

By default, Solaris 10 and earlier run a non-POSIX shell which does not correctly expand the default tmp directory Ansible uses ( ~/.ansible/tmp). If you see module failures on Solaris machines, this is likely the problem. There are several workarounds:

You can set remote_tmp to a path that will expand correctly with the shell you are using (see the plugin documentation for C shell, fish shell, and Powershell). For example, in the ansible config file you can set:

remote_tmp=$HOME/.ansible/tmp

In Ansible 2.5 and later, you can also set it per-host in inventory like this:

solaris1 ansible_remote_tmp=$HOME/.ansible/tmp

You can set ansible_shell_executable to the path to a POSIX compatible shell. For instance, many Solaris hosts have a POSIX shell located at /usr/xpg4/bin/sh so you can set this in inventory like so:

solaris1 ansible_shell_executable=/usr/xpg4/bin/sh

(bash, ksh, and zsh should also be POSIX compatible if you have any of those installed).

Posted Date:- 2021-11-17 08:36:42

How to install Ansible on macOS?

Installing Ansible on macOS is a single-liner command.

It can be installed with the help of “pip”, the Python package manager.

Run the below command to install pip on macOS:

$ sudo easy_install pip
Then install Ansible with:

$ sudo pip install ansible

Posted Date:- 2021-11-17 08:36:16

Does Ansible work with SELinux?

If you have SELinux enabled on remote nodes, you will also want to install libselinux-python on them before using any copy/file/template related functions in Ansible. You can use the yum module or dnf module in Ansible to install this package on remote systems that do not have it.

Posted Date:- 2021-11-17 08:35:22

How do you access a variable name programmatically?

By adding strings together, the variables names are built programmatically like below format:

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

'inventory_hostname' is a variable that represents the present host you are looping over.

Posted Date:- 2021-11-17 08:34:20

How would you copy a file recursively onto a target host?

You can use the copy module with the recursive parameter. If there is a large number of files then the ‘synchronize’ module is the best option to recursively copy a file onto a target host.

Posted Date:- 2021-11-17 08:32:58

How can you see all the variables specific to my host?

To see all the host-specific variables, that include all facts and other resources are:

Ansible - m debug- a “var=hostvars[‘hostname’]” localhost

Posted Date:- 2021-11-17 08:31:35

How can you access a list of Ansible_Variables?

By default, Ansible gathers facts under machines under management. Further, these facts are accessed in Playbooks and in templates. One of the best ways to view a list of all the facts that are available in a machine, then need to run the setup module in the ad-hoc way:

Ansible- m setup hostname

Once this statement is executed, it will print out a dictionary of all the facts that are available for that particular host. This is the best way to access the list of Ansible_variables.

Posted Date:- 2021-11-17 08:29:50

How can you disable cowsay?

If cowsay is installed then executing your playbooks within Ansible is very smooth.

Even if you think that you want to work in a professional cow free environment, then you will have two options:

* Uninstall cowsay
* Setting up value for the environment variable, like below

Export ANSIBLE_NOCOWS=1

Posted Date:- 2021-11-17 08:28:32

Is it possible to increase the Ansible reboot module to more than 600 seconds?

Yes, it is possible to increase the Ansible reboot module to specific values using the below syntax:

- name: Reboot a Linux system

reboot:

reboot_timeout: 1000

Posted Date:- 2021-11-17 08:27:59

How do you access Shell Environment Variables?

If you are just looking to access the existing variables then you can use the “env” lookup plugin.

For example:

Accessing the value of Home environment variable on management machine:

local_home:”{{lookup(‘env’,’HOME’)}}”

Posted Date:- 2021-11-17 08:27:28

How do change the documentation and submit it?

Usually, the documentation is kept in the main project folder in the git repository. For complete instructions on this can be available in docs.

Posted Date:- 2021-11-17 08:27:01

Do we have any Web Interface/ Rest API etc fo

Yes, Ansible Inc makes a great efficient tool. It is easy to use.

Posted Date:- 2021-11-17 08:25:11

Can we manage Windows Nano Server using Ansible?

No, it is not possible to manage Windows Nano Server using Ansible as it doesn't have full access to the .Net framework, which is primarily used by internal components and modules.

Posted Date:- 2021-11-17 08:23:25

Describe your newsletter Ansible and who it’s aimed at.

It appears monthly and has been called the ‘Private Eye’ of science fiction, but isn’t as cruel and doesn’t (I hope) recycle old jokes quite as relentlessly. Though I feel a certain duty to list some bread-and-butter material like conventions, award winners, and deaths in the field, ‘Ansible’ skips the most boring SF news – the long lists of books acquired, books published, book sales figures, major new remainders – in favor of quirkier items and poking fun at SF notables. The most popular departments quote terrible lines from published SF/fantasy and bizarre things said about SF by outsiders (‘As Others See Us’). All the back issues of ‘Ansible’ since it started in 1979 can be read online.

Posted Date:- 2021-11-17 08:21:00

What is the minimal requirement on Managed Nodes under Ansible?

On the managed nodes, you need a way to communicate, which is normally ssh. By default this uses sftp. If that’s not available, you can switch to scp in ansible.cfg. You also need Python 2 (version 2.6 or later) or Python 3 (version 3.5 or later).

Posted Date:- 2021-11-17 08:19:56

Is it possible to manage Windows Nano Server using Ansible?

Windows Nano Server is not currently supported by Ansible since it does not have access to the full .NET Framework that is used by the majority of the modules and internal components.

Posted Date:- 2021-11-17 08:19:33

Tell us about your software company and what sort of software it produced(s).

This goes back to the 1980s and the Apricot home computers, the early, pretty, and non-PC-compatible ones. My pal Chris Priest and I both used them for word processing, and he persuaded me to put together a disk of utilities to improve the bundled ‘SuperWriter’ w/p, mostly written in Borland Turbo Pascal 3 and later 4: two-column printing, automated book index preparation, cleaning the crap out of the spellcheck dictionary, patching SuperWriter to produce dates in UK format, and so on.

Posted Date:- 2021-11-17 08:18:46

Why are you attracted to science and science fiction?

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 favorite 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 a school that made the 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.

Posted Date:- 2021-11-17 08:18:24

How would you describe yourself in terms of what you do and how you’d like to be remembered?

Obviously, I’d like to be remembered as a master of prose who forever changed the face of literature as we know it, but I’m going to have to settle for being remembered as a science fiction writer (and, more and more, critic) who wrote the occasional funny line and picked up a few awards.

Posted Date:- 2021-11-17 08:17:15

Is Ansible a Configuration management tool?

Configuration management is the practice to handle updates and manage the consistency of a product's performance over a particular period of time. Ansible is an open-source IT Configuration Management tool, which automates a wide variety of challenges in complex multi-tier IT application environments.

Posted Date:- 2021-11-17 08:14:37

Can you create reusable content with Ansible?

Yes, Ansible has the concept of roles that helps to create reusable content. To create a role, you need to follow Ansible's conventions of structuring directories and naming files.

Posted Date:- 2021-11-17 08:14:24

What are the variables in Ansible?

Variables in Ansible are very similar to variables in any programming language. Just like any other variable, an Ansible variable is assigned a value which is used in computing playbooks. You can also use conditions around the variables. Here’s an example:


- hosts: your hosts
vars:
port_Tomcat : 8080
Here, we’ve defined a variable called port_Tomcat and assigned the port number 8080 to it. Such a variable can be used in the Ansible Playbook.

Posted Date:- 2021-11-17 08:13:46

How does Ansible synchronize module works?

Ansible synchronize is a module similar to rsync in Linux machines which we can use in playbooks. The features are similar to rsync such as archive, compress, delete, etc but there are few limitations also such as

* Rsync must be installed on both source and target systems
* Need to specify delegate_to to change the source from localhost to some other port
* Need to handle user permission as files are accessible as per remote user.
* We should always give the full path of the destination host location in case we use sudo otherwise files will be copied to the remote user home directory.
* Linux rsync limitations related to hard links are also applied here.

It forces -delay-updates to avoid the broken state in case of connection failure

Posted Date:- 2021-11-17 08:13:03

How does dot notation and array notation of variables are different?

ot notation works fine unless we stump upon few special cases such as

* If the variable contains a dot(.), colon(:), starting or ending with an underscore or any known public attribute.
* If there’s a collision between methods and attributes of python dictionaries.
* Array notation also allows for dynamic variable composition.

Posted Date:- 2021-11-17 08:11:50

What is Ansible Tower and what are its features?

Ansible Tower is an enterprise-level solution by RedHat. It provides a web-based console and REST API to manage Ansible across teams in an organization. There are many features such as

* Workflow Editor - We can set up different dependencies among playbooks, or running multiple playbooks maintained by different teams at once
* Real-Time Analysis - The status of any play or tasks can be monitored easily and we can check what’s going to run next
* Audit Trail - Tracking logs are very important so that we can quickly revert back to a functional state if something bad happens.
* Execute Commands Remotely - We can use the tower to run any command to a host or group of hosts in our inventory.

There are other features also such as Job Scheduling, Notification Integration, CLI, etc.

Posted Date:- 2021-11-17 08:11:14

What is the difference between Ansible and Puppet?

Management and Scheduling: In Ansible, the server pushes the configuration to the nodes on the other hand in puppet, the client pulls the configuration from the server. Also for scheduling, the puppet has an agent who polls every 30mins(default settings) to make sure all nodes are in a desirable state. Ansible doesn’t have that feature in the free version.
Availability: Ansible has backup secondary nodes and puppet has more than one master node. So both try to be highly available.
Setup: Puppet is considered to be harder to set up than ansible as it has a client-server architecture and also there’s a specific language called Puppet DSL which is its own declarative language.

Posted Date:- 2021-11-17 08:10:35

Search
R4R Team
R4R provides Ansible Freshers questions and answers (Ansible Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Ansible Interview Questions for Experienced,Ansible Freshers & Experienced Interview Questions and Answers,Ansible Objetive choice questions and answers,Ansible Multiple choice questions and answers,Ansible objective, Ansible questions , Ansible answers,Ansible MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Ansible fresher interview questions ,Ansible Experienced interview questions,Ansible fresher interview questions and answers ,Ansible Experienced interview questions and answers,tricky Ansible queries for interview pdf,complex Ansible for practice with answers,Ansible for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .