Top 100 Ansible Interview Questions And Answers

Ansible is an open-source IT automation tool acquired by Red Hat – one of the world’s leading providers of enterprise open source solutions – back in October 2015. It was introduced in 2012 with the parent company AnsibleWorks, and has since seen a multifold rise in popularity among the software automation community. 

It’s designed particularly for IT professionals to automate infrastructure, deploy applications, manage configurations, update workstation and server, cloud provisioning, intra service orchestration, and a host of other tasks systems administrator and developers perform on a day to day basis. 

Ansible receives information from your inventory to determine which systems you wish to control. Although , an IP address can be provided to an ad hoc query, inventory is required to fully utilise Ansible’s versatility and reproducibility.

A basic IaC workflow with Ansible

Ever since the Red Hat acquisition, Ansible has only grown in popularity over the years. It’s no wonder more and more companies are asking for candidates with experience in using this hugely popular DevOps or automation tool.

In this guide, we will provide you with the Top 100 Ansible Interview Questions And Answers which are most likely to be asked in your interviews with the top tech companies.

To help you streamline your learning process, we have divided the Q&As into 3 main sectional headings, ranging from beginner-level conceptual questions to highly technical questions for freshers and ansible experience interview questions for professionals alike. 

Contents show

Top 100 Tricky Ansible Interview Questions And Answers

Beginner level Questions And Answers 

1.What is Ansible used for?

Ansible is an open-source tool that automates and streamlines mundane, time-consuming tasks like configuration management, provisioning, and application deployment. It can also provide resources, install services and applications within your cloud.

2.List 5 uses or advantages of Ansible.

  • No agent requirement: Ansible does not require any agents installed on the remote servers. It is an agentless, control-node based automation tool that runs on a control node which remotely administrates Unix or Linux machines and other systems from the control node using SSH authentication. Ansible is also a vendor or consultant’s best choice because of its ability to manage systems without installing new agents.
  • Better network security: Ansible is less vulnerable to attacks because it doesn’t require any remote server agents. The only software you need to execute is the OpenSSH daemon or the WinRM service, which are both among the most critically acclaimed services in the world and form the backbone of encrypted communication access on their respective platforms.
  • A modular automation tool: Ansible automates, deploys, configures, and orchestrates IT infrastructure using modules. Ansible has roughly 750+ modules built-in.Modules (also known as task or library plugins) are small pieces of code that can be run from the command line or a playbook job. Ansible runs each module usually on the remote-controlled node and collects the resultant values.
  • Python support: In order to cater to a wide range of machines, Ansible is able to detect and use Python on many platforms that come with it. You may control nodes with the Ansible Python API, allow Ansible to respond to various Python events, develop plugins, and import inventory data from external data sources.
  • Ansible Playbooks and YAML: Playbooks can finely manage different phases of your infrastructure mesh, with precise control over how many computers to tackle at any given point of time. It makes use of a quite plain language, YAML, in the form of Ansible Playbooks, which allow you to identify your automation tasks in a pattern similar to layman terms.

3.List five disadvantages of Ansible.

  • In comparison to some of its more well-known competitors, Ansible is still in its early stages as an open-source automation tool. It often requires the need to create new modules or use them for other purposes.
  • Ansible is dependent on Python modules on the system that runs the ansible tasks and on the host that runs the playbooks. So, you can’t use Ansible on a host machine without making a provision for it.
  • In case you have a playbook with a lot of tasks to run, it will run tasks one at a time which can be a time-consuming process due to the long time taken between each individual task.
  • One of the major drawbacks of this automation tool is its lack of proper Windows support. Ansible employs native Windows PowerShell remoting rather than SSH in the case of Windows. In short, if you want to manage Windows hosts, you’ll need a Linux-controlled machine.
  • Ansible Tower, which is an upgrade from the previous GUI known as AWX, leaves a lot to be desired. The problems include inconsistent query results generated often to the UI being out of sync with the command line. Overall, it still can’t keep up with the command line interface.

4. What is Configuration management.

Configuration management refers to the process of keeping computer systems, servers, and software in a well maintained state. It’s a method of ensuring that a system continues to perform as expected despite the changes occur over time.

5. What is Orchestration?

The automated configuration, coordination and management of applications, systems, and services is referred to as orchestration. IT can more easily manage and control workflows and complex tasks with orchestration.

6. What is Infrastructure as Code (IaC)? 

Infrastructure as Code (IaC) is the process of provisioning and managing infrastructure via code rather than manual processes.

Configuration files containing your infrastructure specifications are created using IaC, making it easier to modify and distribute configurations. It also makes sure that the same environment is maintained every time.

7. In brief, how does Ansible work?

Ansible connects to your nodes and sends small units, known as modules, to them. In Ansible, modules are used to complete automation tasks.

These units are designed to be resource models for the suitable state of system. Ansible then runs these modules and then gets rid of them once they’re done.

8. What are the basic requirements to set up an Ansible server?

Requirements
Subscription A valid Red Hat Ansible Automation Platform
Operating system Red Hat Enterprise Linux 7.7 or later 64-bit (x86), or 8.2 or later 64-bit (x86)
Ansible version2.9 Version
RAMMinimum 4GB 
CPUsMinimum 2
Disk space20 GB of dedicated hard drive space
(Depends on the size of collections stored)
Browser compatibility Current version of Google Chrome or Mozilla Firefox 

9. What is CI/CD?

The “CI” in CI/CD stands for continuous integration, which is an automation procedure used by the developers. The “CD” in CI/CD stands for continuous delivery or continuous deployment, referring to the automation process in later phases of the pipeline.

From the testing/integration stages to deployment/delivery, CI/CD brings in automation and regular monitoring over the course of an application’s lifespan.

10. What is an Ansible Playbook?

Ansible playbooks are pre-written code that developers can use on the fly or as a starting point. Ansible playbooks are used to automate complicated IT tasks, infrastructure (like operating system/Kubernetes platforms), security systems, and networks on a regular basis. An Ansible inventory is made up of a group, classification, or set of hosts that are all executed by Ansible playbooks.

A sample playbook may look something like below:  

name: Playbook1
 connection: ansible.netcommon.network_cli
 gather_facts: true
 hosts: all
 tasks:
  - name: Get config for VyOS devices
   vyos.vyos.vyos_facts:
    gather_subset: all
  - name: Display the config
   debug:

11. What is Ansible Galaxy?

Ansible Galaxy is a collection of Ansible Roles that can be brought directly into your Playbooks to speed up your automation projects.

Galaxy consists of a large number of roles that are always changing and expanding.

Other role sources like GitHub can be added to Galaxy using git. You can use ansible-galaxy init to create a new galaxy role, or you can use ansible-galaxy install role name> to install a role straight from the Ansible Galaxy store.

Other role sources like GitHub can be added to Galaxy using git. You can use ansible-galaxy init to create a new galaxy role, or you can use ansible-galaxy install role name> to install a role straight from the Ansible Galaxy store.

The command to install Ansible galaxy roles and collections simultaneously with a single command : 

$ ansible-galaxy install -r requirements.yml

12. What are the types of modules in Ansible?

In its codebase, Ansible supports a variety of module types. Some of these are meant for backward compatibility, while others provide flexibility. 

Action Plugins

Action plugins may seem like modules while using playbooks, however, both of them are different. Some action plugins handle everything, while the modules only give out the documentation. Some of these plugins even execute modules. The documentation for the majority of action plugins is to be found in a module with the same name. The controller is where all the action plugins run.

New style modules 

Modules that get shipped with Ansible come under this category. All official Ansible modules use Windows PowerShell or Python. New-style modules come with module arguments, while old-style modules require copying another folder to a controlled node which reduces the efficiency and requires two over the wired connectivity.

13. What is YAML and its uses?

YAML is a serialization language used to create configuration files. YAML stands for yet another markup language or YAML ain’t markup language (which means that YAML is not for documents, but data), depending on the usage.

Ansible’s task is an individual action that aids in further breaking down a configuration policy into smaller files or code blocks. These blocks can be used to automate a procedure like installing a package, updating software etc.

Every YAML file starts with – – – and ends with . . .

---
# A list of alphabets
- A
- B
- C
- D
...

14. What is Ansible Tower?

Ansible Tower (previously known as ‘AWX’) is an internet-based solution that makes Ansible easier to use for IT departments of all types. It’s intended to serve as the central hub for all of your automation projects.

It gives you complete control over who has access to what, including the ability to share SSH credentials without allowing them to be transferred. It keeps track of all of your tasks, merges well with LDAP, and has a web-accessible REST API.

The below playbook file can check for the Tower running a playbook against the inventory. host:

- name: Good luck!
hosts: all
 tasks:
name: Good luck!
  shell: echo "Hi! Tower is working!"

15. What makes Ansible different from Puppet?

AnsiblePuppet
mainly used for configuration, provisioning & deployment mainly used for configuration management & provisioning 
comparatively newer, unpolished GUIbetter developed GUI 
still in infancy with regards to community and support bigger community and support 
written in pythonwritten in Ruby, C++, Clojure
control node; clientless architecture over SSHclient/server; client needs approval by server
installation on control node onlylonger installation procedure 
procedural language; YAMLdeclarative language; puppetDSL with YAML datastore

16. Give an overview of the several different components of Ansible.

Ansible was built for multi-level deployments, and instead of managing one system at a time, it models your IT infrastructure by defining how all of your systems interact.

Modules: Ansible connects to your nodes and sends them “Ansible modules” that script. The majority of modules accept parameters that specify the system’s desired state. Ansible then runs these modules (over SSH) and then deletes them once they’re done. You can also write your own modules.

Module utilities: Ansible stores function as module utilities when different modules use the same code to reduce repetition and maintenance, lib/ansible/module utils/url.py is the code for parsing URLs. You can also create your own module utilities. Only Python or PowerShell can be used to create module utilities.

Plugins: Ansible comes with several useful preloaded plugins, and you can also easily create your own. You can, for example, create an inventory plugin that connects to any JSON-based data source. Python is the only language that can be used to make plugins.

Inventory: Ansible represents the machines it manages by default in a file (like YAML) that combines all of your organized machines into groups of your choice.

There is no need for an additional SSL signing server when adding new machines, so it’s easier to find out why a system didn’t connect due to some arbitrary NTP or DNS issues.

Playbooks: A playbook is a collection of configuration management codes that specify how tasks should be performed on remote networks or a group of network systems. YAML is used to write the codes and instructions.

Run the command $ touch playbook_name.yml to create a playbook.

Ansible search path: You may have multiple files with identical names in different locations on your Ansible control node in case you write your own code to enhance Ansible’s main features. The search path will decide which of these files Ansible will find and use on any particular playbook run.

Over the course of a run, Ansible’s search path expands gradually. Ansible appends any directories related to each playbook and role included in a given run to the search path as it finds them.

17. Define Ad-hoc commands.

Ad-hoc commands are one-line commands that are used to accomplish a particular task. Ad Hoc commands can be thought of as a replacement for playbooks. The following is an example of an Ad Hoc command:

ansible host -m netscaler -a "nsc_host=nsc.xyz.com user=apiuser password=apipass" 

The above Ad Hoc command terminates the server by accessing the netscaler module.

18. What are Ansible variables?

Variables are used by Ansible to manage system differences. With Ansible, you can use a single command to run tasks and playbooks on multiple different systems. During a playbook run, you can also create variables by recording the task’s return value or values as a new variable.

Conditions can also be used around variables.

Variables can be created inline as per below:

- hosts: host1
 vars:
  http_port: 80

19. List differences between environment variable and variable name.

Environment variable Variable name 
To obtain environment variables, you’ll need existing variablesTo create variable names, you must first add strings
You require an advanced Ansible playbook to create environment variablesYou can easily create different variable names by combining strings
For environment variables, we employ {{ ansible_env.SOME_VARIABLE }}For variable names, we will need ipv4 addresses

20. What is an Ansible task?

You can use Ansible Tasks to break down large chunks of configuration policy into separate tiny files. These are reusable code elements that can be used to automate any task. If you want to install a package or update a piece of software, for instance, you can use the code snippet below:

install <package_name>, update <software_name>

21. How do you do a syntax check on Playbook?

If you just want to double-check that everything in the playbook is in order, you u can run a syntax check on your code.

Below is an example of using the command line to do a syntax check on an ansible-playbook

$ ansible-playbook <playbook. yml> --syntax-check

22. How do you dry run a playbook before making actual changes?

You can use the Dry Run feature to view what changes the playbook will make to the server without having to make the actual changes yourself.

To accomplish this, simply add the -C option to your playbook startup task.

23. What is an ask_pass in Ansible?

It determines whether or not an Ansible playbook will ask for a password by default. “No” is the default option:

ask_pass = true

It’s unlikely that you’ll need to change this setting if you use SSH keys for authentication.

24. Define ask_sudo_pass.

It controls whether an Ansible playbook should ask for a sudo password by default, same as ask_pass. 

No is also the default option.

ask_sudo_pass = true.

Users with sudo passwords enabled on their platforms can modify this setting.

25. What is ask_vault_pass?

This determines whether or not an Ansible playbook will ask for the vault password by default. No is the default option.

ask_vault_pass = true

26. What is Callback_plugin in Ansible?

Ansible callbacks are bits of scripts that are executed when certain events occur, allowing notifications to be triggered.

This is a developer-focused feature that allows low level Ansible extensions to be loaded from multiple sources.

To get a list of all the callback plugin ansible-doc -t callback -l

27. Where is unit testing present in Ansible?

Unit tests are located in the test/units directory. It’s worth noting that the tests’ directory structure is similar to that of lib/ansible/.

28. What command would you use to install Ansible on CentOS?

First, make sure that CentOS EPEL repository has been installed

$ sudo yum install epel-release

Then, install Ansible using yum

$ sudo yum install ansible

29. What is Async?

It’s a task that’s set to run in the background instead of waiting for it to finish. It’s better to start a process in async mode in case it takes longer than the SSH timeout. Async modes can be set to check for completion every several seconds or to ‘fire and forget’, in which case Ansible will not look up the task again and move on to the next step. 

/usr/bin/ansible and /usr/bin/ansible-playbook both support Async mode.

30. What does the Connection plugin do?

Ansible uses connection plugins to connect to target hosts and perform tasks on them. Ansible comes with a lot of connection plugins, but each host can only use one at a time. Most commonly used include SSH(Native), Paramiko SSH and local connection type.

31. What is Diff Mode?

Ansible’s –diff playbook option can be used alone or in combination with –check. Any module that supports diff mode shows the changes made and when used with –check, it shows the changes that would have been made, when run in diff mode. Diff mode is mostly used in file manipulation modules (for instance, the template module).

32. What is an Executor?

It is a core Ansible software component that enables /usr/bin/ansible and coincides with every task execution in an ansible playbook. Although Ansible developers use the term ‘executor’ it is not widely popular.

33. What does Filter Plugin do?

Filter plugins can modify data. These enable the development of new Jinja2 filters, which are primarily useful to people who are already familiar with Jinja2 filters.

34. Explain the use of Forks.

Ansible communicates with the remote nodes in parallel, and the level of parallel processing can be changed by passing –forks or editing the current configuration file.

35. What does gather_facts do?

This module is responsible for running the enabled facts modules; the setup module is used by default. Playbooks call this module automatically to gather useful information about remote hosts that can be needed in playbooks.

36. What is Globbing?

Globbing is a method of selecting a large number of hosts based on wildcards instead of the host’s or group’s specific names. For instance, you can use the wildcard ww* to find and match all servers that begin with the www.

37. What do you store in group_vars?

The group_vars/ files stay in the same directory as the inventory file, with a filename labeled after each group. This is a good place to store variables that are provided to a specific group, especially complicated data structures, so they don’t have to be included in the inventory file or playbook.

38. What is a Handler?

Handlers are similar to regular tasks in an Ansible playbook (see Tasks), except that they are only executed if the Task contains the notify keyword and also indicates that something changed.

39. What do Host Vars do?

A directory known as host vars the inventory file can contain YAML files labeled after every hostname in the inventory file, just like Group s3eVars.

40. What is idempotency?

If the result of performing an operation once is identical to the result of performing it repeatedly without any external influence, it is said to be idempotent.

41. What is the the language used in the Ansible template module?

Ansible’s template module uses Jinja2 as its choice of templating language. It’s a very basic Python template language that’s both legible and simple to write.

42. What is Lazy Evaluation?

Ansible evaluates any variables in playbook content at the very last second, which means that if you specify a data structure, that structure can specify variable values inside it.

43. What does Lookup Plugin do?

A lookup plugin is a way to import data from the right into Ansible. Lookup plugins are just an offshoot of Jinja2 that can be used in templates, such as lookup{{ lookup(‘file’,’/path/to/file’) }}. This is how features like with_items are executed. There are also lookup plugins for querying DNS records, environment variables, key-value records, and file that will load data from a file.

44. Explain the use of Limit Groups.

The commands can be restricted to a subset of hosts by passing –limit the group to ansible or a playbook. This could be used, for example, to execute a playbook that usually addresses an entire range of servers to a single server.

45. What is a Pull Mode?

When you want nodes to check in every few minutes on a specific schedule, you can use pull mode. It works with the ansible pull program and can also be configured/or reconfigured with a push-mode playbook.

46. What is a Push Mode? 

Ansible runs in push mode by default, giving it complete authority when it communicates with every system. Ansible can operate nodes through intricate orchestration procedures without having to wait for them to check-in, while using push mode.

47. Define Register Variable.

Ansible register allows you to save the output of a task’s execution in a variable. This is a significant feature because the output varies by the remote host, and we can use conditions loops to perform other tasks based on it. Furthermore, each register value remains valid throughout the execution of the playbook.

48. How does the Resource Module work?

A “Resource Module” is a discrete network component that has been mapped to a single Ansible module. 

Network devices divide configuration into sections that apply to a network service (like VLANs and interfaces). This is used by Ansible network resource modules to allow you to set up subsections or resources within a network system configuration.

49. What is a Rolling Update?

The action of referring to a group of N nodes is taken one at a time in order to prevent upgrading them all at once and getting the system offline. For example, to handle a web topology with 500+ nodes it might make sense to finish updating only 10 to 20 machines at a time and then move on to the next ones. In Ansible playbooks, the serial: keyword manages the size of the rolling update. By default, the batch size is handled all at once.

50. What are Ansible facts?

Ansible maintains information on the host in variables after running a setup module on it for easy access in playbooks. Ansible facts are pre-defined variables that provide information about a host system.

Intermediate level Ansible Interview Questions And Answers 

51. How do you check variables for a host?

The host_vars variable provides access to all of a host’s variables. It’s a variable dictionary with the title of the variable as the key. Here’s an illustration:

ansible -m debug -a  "var=hostvars[inventory_hostname]"

52. What are tags? How do I get rid of tags?

A tag is an attribute that you can apply to a play or tasks so that you can pick or deselect them when you run a playbook. There are two methods for removing tags from a list:

Use the –tags or –skip-tags command line options.

Using the TAGS RUN and TAGS SKIP parameters in the Ansible setup settings, disable or enable tags.

53. Is Ansible compatible with SELinux?

If you wish to use any copy/template functions in Ansible, you’ll need to install libselinux python on remote nodes that have SELinux enabled. Ansible’s yum or dnf modules can be used to install this package on remote systems that don’t already have it.

54. How can you create encrypted files with Ansible?

Use the ‘ansible-vault create’ command to generate an encrypted file.

$ ansible-vault create filename.yaml

You’ll be prompted to establish a password, which you must then confirm by typing it again. You’ll now have access to a new file in which you can add and change information.

55. Is there any way to increase reboot timeout value?

Yes, the Ansible reboot module’s 600-second wait time can be increased to specified levels. The following syntax can be used:

Expert level Ansible Interview Questions And Answers For Experienced Professionals

55. How do you put Ansible projects to the test?

This is another common ansible interview question. There are three options for testing:

Asserts

Asserts replicates the test’s behavior in other languages, such as Python. It ensures that your system has reached the intended state, rather than just a simulation like in check mode. Asserts that the task completed the task’s objectives and that the necessary resources were modified.

Check Mode

Check mode displays how things would work if no simulation had been performed. As a result, it’s simple to see if the project behaves the way you want it. Check mode, on the other hand, does not run scripts and commands that are used in roles and playbooks. To get around this, use ‘check mode: no’ to disable check mode for specified tasks.

Manual Run

Simply execute the play and ensure that the system is in the required state. This type of testing is the simplest, but it comes with a higher risk because the results in a test environment may differ from those in a production environment.

56. What is Ansible Vault, and how does it work?

Any structured data file used by Ansible can be encrypted using the Ansible Vault functionality. This can contain inventory variables like group vars/ or host vars/, variables loaded using include vars or vars files, or variable files supplied with -e @file.yml or -e @file.json on the ansible-playbook command line. Variables and defaults for the roles are also supplied!

Ansible jobs, handlers, and other objects contain data, therefore the vault may encrypt them as well. You can keep an individual task file completely encrypted if you don’t want to reveal the variables you’re utilizing.

57. How can you get access to shell environment variables?

Using the “env” lookup plugin, you can get at the variables that the controlling computer already has. To get the value of the home environment variable on the management computer, for example, type:

local home:'{lookup(‘env’,’HOME’)}}'

58. In a playbook, how do you keep data hidden?

Use Vault in playbooks if you want to maintain confidential data but still be able to publish it publicly. However, if you’re using –v (verbose) mode and don’t want the results to be visible to others, use:

name: secret task
shell: /usr/bin/do_something --value={{ secret_value }}
no_log: True

59. How can I configure the pre-reboot and post-reboot delays?

After the reboot has completed successfully and the connection has been re-established in seconds, the following command can be used to force Ansible to wait:

- name: Unconditionally reboot the machine with all defaults
 reboot:
  post_reboot_delay: 180

Interview Questions on Ansible Playbooks

60. Describe the syntax of the Playbook.

Playbooks are written in YAML and have very little syntax.

A playbook is a collection of one or more ‘plays’ in a logical order. Each play carries out a portion of the playbook’s ultimate goal by carrying out one or more responsibilities. An Ansible module is called by each task.

61. Describe how the Playbook is put into action.

From top to bottom, a playbook is read. Tasks are also completed in order from top to bottom inside each play. Multiple ‘plays’ in a playbook can orchestrate multi-machine deployments, with one play operating on your webservers, another on your database servers, a third on your network infrastructure, and so on. Each play must define at least two things:

  • the managed nodes to target
  • with at least one job to execute

62. How are Ansible playbooks used?

The YAML syntax is used in Ansible. YAML means “yet another markup language” or “YAML isn’t a markup language.” YAML file extensions include.yaml and.yml.

Ansible playbooks can be used in two ways:

1. Using a command-line interface (CLI)

2. Push-button deployments with the Red Hat Ansible Automation Platform.

63. What is the best way to run playbooks?

Use the ansible playbook command to run your playbook.

ansible-playbook playbook.yml -f 10

When running your playbook, use the —verbose parameter to receive full output from both successful and failing modules.

64. What is Ansible-Pull?

If you want to invert Ansible’s architecture such that nodes check in to a central place rather than pushing configuration out to them, you can use Ansible Pull.

Ansible Pull is a tiny script that will fetch a git repository of configuration instructions and then execute ansible playbook against it.

Ansible Interview Questions for Devops Engineer

65. What method will you use to disable Cowsay?

If Cowsay is installed, integrating your playbooks into Ansible is a breeze. Regardless of whether you believe you need to work in a professional cow-free environment, you will have two options:

  • Remove cowsay from your computer.
  • Export ANSIBLE NOCOWS=1 to set the value for the environment variable.

66. How will you make EC2 management more efficient?

Managing a collection of EC2 machines from your PC is not possible.

The best approach is to first connect to an Ec2 administrative node and then use Ansible from there.

67. What method will you use to upgrade Ansible?

Upgrading Ansible is simple. You must use the following command:

Ansible== Sudo Pip Install

68. Is there a reference for Ansible API somewhere?

Yes, Ansible can handle Rest API calls using ansible tower. It offers the option of using RBAC to obtain ssh certificates in a secure manner.

69. Is it possible to use Ansible to provision hardware?

Yes, Ansible can set up equipment. Many firms are still reliant on massive data servers. There are a few requirements. Before you proceed, you should set up some administrative procedures. PXE, DHCP, Operating System Media, TFTP, Web Server, and others are among them.

70. What is a Controller Machine, and what is it used for?

The Controller machine is in charge of provisioning the servers under its control. In this machine, Ansible is used.

Ansible Architecture Interview Questions

71. Describe Inventory

Inventory refers to listings of nodes or hosts with IP addresses, databases, servers, and other items that must be controlled.

Ansible’s default representation of the machines it manages is a simple INI file that groups all of your managed computers into groups of your choosing.

Variables can be allocated to inventory hosts in simple text files in the ‘group vars/’ or ‘host vars/’ subfolder or directly in the inventory file.

72. What is the CMDB database?

A CMDB is a sort of database that serves as a data warehouse for IT systems.

Ansible Tower Interview Questions

73. How to use Ansible Tower?

  • First, create an Inventory with a sample Host
  • Then, create a Project where Tower will retrieve the playbook from
  • Create a credential
  • Make a template for job

74. What is Ansible Tower?

Ansible Tower is Ansible’s user interface, dashboard, and REST API. With role-based, job scheduling, access control, and graphical inventory management, you can manage your Ansible infrastructure from a modern UI. Tower’s REST API and command-line interface make it simple to integrate Tower into current tools and procedures.

Ansible Interview Questions Multiple Choice

75. What language was the Ansible engine written in?

  • Python
  • Java
  • C++
  • C#

76. What year did Ansible first come out?

  • February 2012
  • March 2012
  • April 2012
  • January 2012

77. What is the default language in which Ansible playbooks are written?

  • XML
  • HTML
  • JSON D
  • YAML

78.  In your Ansible playbook, which parameter will you use to specify a variable?

  • None of them
  • -c
  • -d
  • -e

79. What does IaC stand for?

  • Infrastructure as Code
  • Integration and Code
  • Into as Code
  • Intra as code

80. Does YAML use tabs for indentation?

  • True
  • False

81. By default, what is the Inventory file location?

  • rolename/tasks/
  • playdir/{files|vars|templates}/
  • /etc/ansible/hosts
  • /usr/bin/env

82. The module that can be used to copy files from remote machine to control machine.

  • copy
  • fetch
  • template 
  • file

83. What command would you want to omit facts from the host?

  1. gatherfacts: no
  2. gatherfacts: False
  3. i only
  4. both 1 and 2

84. What configuration management tool does not require the use of an agent?

  • SaltStack
  • Ansible
  • Chef
  • Puppet

85. Ansible modules will make modifications each time you run a playbook 

  • True
  • False 

86. Which ansible module can be used to temporarily halt a playbook’s execution?

  • identity
  • inventory
  • commands
  • pause

87. Even if you run the playbook multiple times, the handler will only run once.

  • True
  • False

88. Which of the following directives should be used for overriding the default method set in Ansible?

  • ansible_become_method
  • become_user
  • become_method
  • ansible_become

89. By default, what is the Forks configuration value in Ansible?

  • 1
  • 3
  • 6
  • 5

90. Does Ansible require root access to execute tasks?

  • True
  • False

91. What is the default value of Poll_interval in Ansible configuration?

  • 15
  • 13
  • 20
  • 9

92. Which module should you use to make a handler execute between two tasks?

  • apt_key
  • acl
  • add_host
  • meta

93. Which Ansible module oversees the management of Docker services and containers? 

  • docker_host
  • docker_service
  • systemd
  • slurp

94. Which module allows you to see a list of all the Ansible variables?

  • dnf_module
  • service
  • setup
  • copy

95. Which command do you use to check the syntax of your Ansible playbook?

  • $ sudo apt-add-repository 
  • $ ansible-playbook <playbook. yml>
  • ansible -i hosts all -m copy -a 
  • shell: apt-get install clamav -y 

96. Which of these will randomly loop through items?

  • with_dict
  • with_together
  • with_list
  • with_random_choice

97. Which of the below options are used for privilege actions in Ansible?

  • become: yes
  • become_user: apache
  • command: somecommand
  • become_method: sudo

98. How can I see all the inventory variables that have been specified for my host?

  • ansible -m setup hostname
  • ansible-inventory –list –yaml
  • {{ hostvars[inventory_hostname][‘somevar_’ ~ other_var] }}
  • remote_tmp=$HOME/.ansible/tmp

99. Which of the following is used to encrypt files and variables in Ansible?

  • ansible debugger
  • ansible pull
  • ansible playbook
  • ansible vault

100. Which Ansible module can you use to create a directory?

  • inventory
  • meta
  • file
  • data

Given that Ansible is a fantastic tool for automating IT operations and that it is frequently used in industries, any software engineer or member of the DevOps team should be familiar with its fundamental concepts.

Furthermore, it is incredibly simple to set up, so we can get started right away. These questions cover the most significant aspects connected to Ansible and will assist you in both preparing for and understanding Ansible in more depth during your interview.