Ansible Interview Questions
Last updated on Jan 09, 2024
DevOps is drawing in a great deal of consideration nowadays, which implies anything related with it additionally gets the importance, welcoming expanded interest and investigation. Ansible is a vigorously preferred DevOps device, explicitly in the domain of programming robotization. Since Ansible is expanding in ubiquity, it makes sense that more organizations and associations are searching for competitors who have experience utilizing it. This raised interest implies there's a higher probability of having Ansible-related inquiries tossed at you during an interview. In this article, you can go through the set of frequently asked Ansible interview questions and answers in the interview panel. There will be questions for beginners, at intermediate level and of experienced level. This will help you crack the interview as the topmost industry experts curate these at HKR training.
Most Frequently Asked Ansible Interview Questions
Let us have a quick review of the Ansible interview questions,
How do you set up Ansible?
Ans: You could utilise either a Linux-based installation process or the Python installer, such as apt or yum.
Can you increase the Ansible reboot module to more than 600 seconds?
Ans: Yes, it is acceptable to increase the Ansible reboot module to particular values utilising the given syntax:
- name: Reboot a Linux system
reboot:
reboot_timeout: 1000
Define ad hoc command.
Ans: ad hoc commands are initiated by users to initiate actions on a host without making use of a playbook. It can be considered as a one-shot command.
Become a Ansible Certified professional by learning this HKR Ansible Training !
How do you alter the documentation and submit it?
Ans: The documentation is placed in the principal project folder in the git repository usually. The complete instructions on documentation are accessible in docs.
Is Ansible a Configuration management tool?
Ans: Configuration management is the training to deal with updates and oversee consistency of an item's presentation throughout a specific timeframe. Ansible is an open-source IT Configuration Management device, that robotizes a wide assortment of difficulties in complex multi-level IT application conditions.
Related Article: Ansible shell vs command !
When will you use {{ }}?
Ans: Ansible’s most important basic rules is: “Always use {{ }} except when:”
Ansible Galaxy
Ans: This is an apparatus packaged with Ansible to make a base registry structure. It is a site which allows clients to discover and share Ansible script. You can utilize this order to download roles from the site.
Differentiate between a playbook and a play.
Ans: A play is a collection of tasks which operate on one or more managed hosts. Plays comprise one or more tasks. A playbook comprises one or more plays.
How can you copy files recursively onto a target host?
Ans: The copy document in Ansible has a recursive boundary. Assuming you need to duplicate documents for countless records, the synchronizing module is the most ideal decision for it.
. Is there any Web Interface/ Rest API etc for Ansible?
Ans: Yes, Ansible Inc creates a great excellent tool which is simple to utilise.
. Define tags
Ans: It’s more advisable to operate just a part of it as opposed to the whole thing, when there’s an extensive playbook incorporated.
. How will you disable Cowsay?
Ans: On the off chance that Cowsay is introduced, implementing your playbooks inside Ansible is extremely smooth. Regardless of whether you imagine that you need to operate in an expert cow free climate, at that point you will have two alternatives:
- Uninstall cowsay
- Setting up value for the environment variable,
Export ANSIBLE_NOCOWS=1
. Define ask_pass module.
Ans: An ask_pass module is a playbook control module used to command a password prompt. It’s set to True by default.
Want to know more about Ansible,visit here Ansible Tutorial !
. How will you filter out tasks in tags?
Ans: Utilise tags or skip-tags options on the command line. If you are using Ansible configuration settings, then utilise the TAGS_RUN and TAGS_SKIP options.
. Ansible Tower
Ans: Ansible Tower is an enterprise level electronic solution which builds Ansible's openness to other IT groups by incorporating a simple to utilize (UI). Its essential capacity is to fill in as the center point for the entirety of an association's computerization undertakings, permitting clients to screen setups and lead fast deployments.
. Is it possible to manage Windows Nano Server using Ansible?
Ans: No, it is not possible to handle Windows Nano Server utilising Ansible as it dont have the complete access to the .Net framework, that is mainly utilised by internal segments and modules.
. What are the tasks of Ansible?
Ans: Ansible can do the given tasks:
- IT orchestration
- Configuration management
- Task automation
- Application deployment
. Explain the requirements for the Ansible server.
Ans: You require a virtual machine having Linux installed on it, operating with Python version 2.6 or higher.
Related Article: Terraform vs Ansible !
. How will you speed up management within the EC2?
Ans: It is not feasible to deal with a gathering with respect to EC2 machines from your PC.The most ideal route is to associate with an administration node inside Ec2 first and afterward implement Ansible from that point.
. How will you view all the variables specific to my host?
Ans: To view all the host-specific variables, which incorporate all facts and other resources are:
Ansible - m debug- a “var=hostvars[‘hostname’]” localhost
Ansible interview questions for Intermediate
. How will you upgrade Ansible?
Ans: It is simple to upgrade Ansible. You have to use this command:
sudo pip install ansible==
Ansible Training
- Master Your Craft
- Lifetime LMS & Faculty Access
- 24/7 online expert support
- Real-world & Project Based Learning
. Define idempotency.
Ans: Idempotence is an essential Ansible feature that allows you to run one or more tasks on a server as many occasions as you need. Further, it also stops useless changes to the managed hosts. It will not modify anything which has already been changed and is working perfectly.
. Explain handler.
Ans: The handlers in Ansible are actually similar to typical tasks in a playbook yet operate when assignments incorporate the notify mandate and furthermore show that it altered something. It operates just once every one of the tasks implemented in a specific play. It consequently stacks through roles//handlers/main.yaml. They are utilized to trigger the situation with an assistance, for example, restarting or halting a service.
. Differentiate between a variable name and an environment variable?
Ans: Variable name
- You have to include strings to make variable names
- You could easily make multiple variable names by adding strings
- We utilise the ipv4 address for variable names
Environment variable
- You require existing variables to avail the environment variables.
- To make environment variables we should refer advanced Ansible playbook
- We use {{ ansible_env.SOME_VARIABLE }} for remote environment variables.
. How will you use Ansible to make encrypted files?
Ans: Utilise the ‘ansible-vault create’ command to make an encrypted file.
$ ansible-vault create filename.yaml
You will receive a prompt to make a password, and afterwards to type it again for confirmation. You will then have access to a new file, which enables you to include and edit data.
. Callback plugin in Ansible?
Ans: Callback modules empower including new practices to Ansible while reacting to events. Naturally, callback plugins command the vast majority of the yield you view when operating the command line program. It can likewise be utilized to add extra output, coordinate with different apparatuses, and so on.
. How does Ansible work?
Ans: Ansible is separated into two sorts of servers: nodes and controlling machines. Ansible is introduced on the controlling PC, and the controlling machines deal with the nodes through SSH. The controlling machine includes a stock record which has the nodes framework's area. Ansible operates the playbook on the controlling machine to send the modules on the node frameworks. As Ansible is agentless, there's no requirement for an outsider device to associate the nodes.
[ Related Article : Ansible Training in Hyderabad ]
. Configuration management tools
Ans: Configuration management tools assist to keep a framework functioning inside the ideal boundaries. They aid to lessen arrangement time and significantly decrease the exertion needed to perform dreary assignments. Mainstream configuration management apparatuses available today incorporate Chef, Salt, Puppet, and obviously, Ansible.
. Explain playbook
Ans: A Playbook is a file in which Ansible code is written in YAML format. Playbooks are Ansible’s core elements, and they generally include the tasks that need to be automated or run.
. Are you aware of any API reference for Ansible ?
Yes, Ansible deals with Rest API calls that can be accomplished by utilizing ansible tower. It provides an alternative to utilize RBAC which is protected to avail the ssh certifications.
. What are facts?
Facts are newfound and known framework factors which are found in the playbooks, utilized generally for carrying out conditionals implementations. Also, they assemble specially ad hoc framework data. You can receive all the facts by utilising this command:
$ ansible all- m setup
. Is it conceivable to construct our modules in Ansible?
Ans: Yes, we can make our own modules inside Ansible. It's an open-source apparatus which fundamentally deals with python. You can begin making your own modules. The lone prerequisites are incredibly acceptable at programming.
Subscribe to our YouTube channel to get new updates..!
. Does Ansible support hardware provisioning?
Ans: Yes, Ansible can provision equipment. A ton of organizations are as yet adhered onto enormous data servers of hardware. There are a couple of prerequisites. You should set up certain administrations before you go on. Some of them are PXE, DHCP, Operating System Media, TFTP, Web Server, and so on.
. Define Controller Machine
Ans: A Controller Machine is accountable for the provisioning of servers that are being governed. However, it is the device where Ansible is placed.
. What are Ansible roles and how to create Ansible roles?
Ans: Ansible roles include many playbooks. They are a method to group different tasks together into a single container. They are reusable scripts. Through using the given command we could create ansible roles.
Ansible-galaxy init
. Disadvantages of Ansible
- Underdeveloped GUI with restricted highlights
- Need root SSH access and Python introduced on machines, despite the fact that specialists are not needed
- Expanded spotlight on arrangement over configuration management.
- SSH correspondence eases back down in scaled conditions.
- The syntax across scripting parts, for example, playbooks and layouts can change.
. Is it possible to create reusable content with Ansible?
Ans: Yes, Ansible has the idea of roles that assists with making reusable substance. To make a role, you are required to follow Ansible's shows of organizing indexes and naming documents.
. What are CD and CI?
Ans: Disc represents continuous conveyance, and CI represents continuous integration; both are programming improvement methods. In CD, designers fabricate programming that can be delivered into creation at some random time. CI, then again, comprises every engineer transferring consistently booked reconciliations (typically day by day), bringing about numerous combinations consistently. Ansible is an ideal apparatus for CI/CD methods, giving a steady foundation to provisioning the objective climate and afterward conveying the application to it.
. Components of Ansible
Ans: Ansible automation includes the given elements:
- Playbooks
- APIs
- Modules
- Cloud
- Inventories
- Host
- Networking
. Does Ansible support AWS?
Ans: There are hundreds of modules which are included in Ansible which support AWS. It incorporates:
- Security Groups
- CloudTrail
- CloudFormation
- Autoscaling groups
- Virtual Private Cloud (VPC)
- Elastic Cloud Compute (EC2)
- Relational Database Service (RDS)
. What are the variables in Ansible?
Ans: Variables in Ansible are very much like factors in any programming language. Very much like some other variable, an Ansible variable is appointed a worth that is utilized in processing playbooks. You can likewise utilize conditions around the factors. An example is given below:
- hosts: your hosts
vars:
port_Tomcat : 8080
Here, we've characterized a variable known as port_Tomcat and allotted the port number 8080 to it. A particular variable can be utilized in the Ansible Playbook.
. How to make an empty file using Ansible?
Ans: Ansible utilises a file module to make an empty file.We require to set up two parameters for making this.
Path - It represents the location where the file gets made, either an absolute path or the relative. The name of the file is also incorporated here.
State - This parameter must be built to touch.
. How will you utilize docker modules in Ansible?
Ans: Docker modules need docker-py installed on the host operating Ansible.
$ pip install 'docker-py>=1.7.0'
The docker_service module also needs docker-compose
$ pip install 'docker-compose>=1.7.0'
. What is Ansible?
Ans: Ansible is an open-source IT mechanization engine which has numerous modules for associating with applications and administrations that a DevOps engineer requires. It can computerize application sending, intra-administration arrangement, and the total app lifecycle. It was created by Michael DeHaan and was at first delivered in 2012. It doesn't utilize a custom security framework on the customer side. The modules are forced to customers. In the wake of executing these modules locally on the customer side, the functioning outcome is pushed back to the servers of Ansible. Associating with customers with Ansible is basic as SSH keys are utilized. Customer subtleties like IP address and hostname are put away in inventory documents that Ansible can utilize. Playbooks are a significant piece of Ansible which is coded utilizing a language called YAML. Precarious functions are altered into repeatable playbooks to rearrange the design. These playbooks can be effortlessly perceived and fixed if essential. Ansible is coded utilizing the Python programming language. The servers which must be designed require Python libraries.
. Advantages of Ansible
- The playbooks could be utilized without requiring any programming aptitudes. It is easy to set up Ansible.
- Arrangement of any application climate is conceivable independent of where it is sent.
- For computerizing customer frameworks, no product or firewall ports must be introduced. A different administration structure isn’t needed.
- Conveying multi-level applications is much simpler. There is no requirement to arrange these applications physically on each machine.
- Ansible assists engineers with robotizing every day configuration management functions. It saves their time and they can zero in on other significant errands.
. Define Ansible Task
Ans: Ansible Tasks permit you to separate pieces of setup strategy into more small documents. These are blocks of code which can be utilized to mechanize any cycle. For instance, on the off chance that you want to introduce an update of a product, you can follow the underneath code:
Introduce, update
. How to access shell environment variables.
Ans: You can get to the controlling machine's current factors by utilizing the "env" query module. For example, to get to the estimation of the administration machine's home climate variable, you'd enter:
local_home:”{{lookup(‘env’,’HOME’)}}”
. Ansible Vaults and its uses
Ans: Ansible Vault is a component that permits you to maintain every one of your secrets safe. It can encode whole records, whole YAML playbooks or even a couple of factors. It gives an office where you can encode sensitive information as well as coordinate them into your playbooks. Vault is executed with record level granularity where the documents are either altogether scrambled or totally decoded. It utilizes a similar password for encrypting just as for decoding records which creates utilizing Ansible Vault very easy to understand.
. Explain the concept behind Infrastructure as Code (IaC).
Ans: Infrastructure as Code (IaC) is an interaction for overseeing and working information servers, stockpiling frameworks, framework designs, and organization foundation. In conventional setup management methods, every moment arrangement change needs manual activity by framework directors and the IT support group. Be that as it may, with IaC, all the arrangement subtleties are handled and put away in a normalized record framework, wherein the framework naturally handles foundation changes and manages framework configurations. So we don't need the majority of the manual exertion as everything is handled and computerized by the IaC approach. Ansible can be utilized to carry out IaC approach.
. Comparison between Chef and Ansible
- Installation and setup : No specialists are executed on customer machines for Ansible and no customer server establishment is required. SSH associations are utilized for signing in a customer's PC and arranging the hubs. No unique arrangement is needed for the customer's virtual machine. Hence, the establishment is simple. In Chef, the server will operate on the expert machine. All tried configurations are put away in workstations that are forced to the focal server of Chef.
- Configuration management : Ansible utilizes YAML (Yet Another Markup Language) for dealing with its setups. This language takes after the English language and is easy to comprehend. Utilizing YAML, the arrangements are forced into the individual nodes. Ruby Domain Specific Language is utilized in Chef. The language pulls arrangements from the server.
Pricing : For essential IT tasks with Ansible, you need to pay $10,000/year for 100 nodes, incorporating 8×5 help.The top notch bundle comes for $14,000/year with 24×7 support. Chef is more reasonable as it accompanies $137/hub, including all you need to create and send.
State/dynamic inventories : Ansible could utilize static and dynamic inventories, for example, a level INI document containing hosts isolated into segments. This adaptability isn't provided by Chef as you need to separately enroll hosts on the Chef worker.
Source of truth : The source of truth is the legitimate arrangement for a framework. In Ansible source control frameworks, for example, Git can be utilized as a source of truth. The Chef server goes about as the source of truth. Here, you need to transfer refreshed cookbooks, now and then to different servers. It is hard to keep up the consistency of cookbooks along these lines.
. Where do you find Unit Tests in Ansible?
Ans. The unit tests in Ansible are located in the directory tests/units/modules. These tests cover the internal as well as the Ansible modules.
. Define ask_sudo_pass.
Ans. The term ask_sudo_pass is similar to ask_pass, where the ask_sudo_pass manages the Ansible Playbook so that it prompts a sudo password while sudoing. However, the default behaviour consists of no: ask_sudo_pass = True.
. Define YAML File.
Ans. YAML refers to Yet Another Markup Language. A YAML file is similar to the formatted text file, having a few sets of regulations similar to the XML or JSON. Ansible uses YAML syntax for playbooks because they are more readable than others.
. Define the Ansible Inventory and its types.
Ans. An Ansible Inventory is a file that defines hosts and groups of hosts on which the commands, tasks, and modules inside the Ansible Playbook run. There are two types of Ansible Inventory, Static and Dynamic.
nclusion
Thus, by experiencing the above questions you can pick up a fundamental impression of the frequently asked Ansible interview questions that you can expect in the interview panel. Aside from theAnsible interview questions referenced above, you can locate a wide cluster of hotspots for nitty gritty interview questions and answers. You can utilize such sources for picking up a comprehension of each Ansible interview question.
Upcoming Ansible Training Online classes
Batch starts on 26th Dec 2024 |
|
||
Batch starts on 30th Dec 2024 |
|
||
Batch starts on 3rd Jan 2025 |
|