If you're looking for Ansible Interview Questions, you are at right place. There are lot of opportunities from many reputed companies in the world. According to research Ansible has a market share of about 4.4%. So, You still have opportunity to move ahead in your career in Ansible vs Puppet. Mindmajix offers advanced Ansible Interview Questions that helps you in cracking your interview & acquire dream career.
Q. What is Ansible?
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.
Q. How Ansible Works?
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.
Q.What’s the Use of Ansible.
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.
We’ve compiled a series on Ansible, title ‘Preparation for the Deployment of your IT Infrastructure with Ansible IT Automation Tool‘, through parts 1-4 and covers the following topics.
Q. 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.
Q. 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 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.
Q. 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.
Then I redid the index software (‘AnsibleIndex’) in CP/M for the Amstrad PCW and its Locoscript word processors. When the Apricot market collapsed, I wrote an Apricot emulator in assembler so that people could keep using their horrible but familiar old software on a PC. Eventually, in a fit of nostalgia, I collected all my columns for ‘Apricot File’ and various Amstrad PCW magazines as books unoriginally titled ‘The Apricot Files’ and ‘The Limbo Files’. (That’s probably enough self-promotion, but there’s lots more at HTTP://ANSIBLE.CO.UK/.)
Q. 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 favour 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.
Q: What are the advantages of using Ansible?
The main three advantages of using this tool is,i.e. Ansible
2. Very low overhead
3. Good performance
Q: So how does Ansible work? Please explain in detail?
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
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.
Q: Do we have any Web Interface/ Rest API etc for this?
Yes, Ansible Inc makes a great efficient tool. It is easy to use.
Q: What is Ansible Tower?
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.
Q: 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.
Q: How do you access Shell Environment Variables?
If you are just looking to access the existing variables then you can use “env” lookup plugin.
Accessing the value of Home environment variable on management machine:
Q: How can you speed up management inside in EC2?
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.
Q: 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:
1. Uninstall cowsay
2. Setting up value for the environment variable, like below
Q: 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 you 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.
Q: How can you see all the inventory variables that are defined in the host?
The best way to see all the inventory variables is by executing this command below:
Ansible - m debug- a “var=hostvars[‘hostname’]” localhost
Q: Why don’t you ship in X format?
They are several reasons for not shipping in X format. In general, it caters towards maintainability. Within the market, they are tons of different ways to ship software and it is very tedious to support all of them.
Q: What is that Ansible can do?
Ansible can do the following for us:
1. Configuration management
2. Application deployment
3. Task automation
4. IT orchestration
Q: Please define what is Ansible Galaxy?
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
Q: Do you know what language Ansible is written in?
Ansible is written in Python and PowerShell
Q: Please explain what is Red Hat Ansible?
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:
2. Deploying applications
3. Orchestrating workflows
4. Manage IT systems
5. Configuration of IT systems
All of these activities are dealt by Ansible where it can help the business to solve the real time business problems.
Q: Is Ansible is an open source tool?
Yes, Ansible is an open source tool which is a powerful automation software tool that one can use.
Q: 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 the knowledge 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.
Q: What are Ansible server requirements?
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.
Q: How can you connect to other devices within Ansible?
Once, Ansible is installed and the basic setup has been completed, an inventory is created. This would be the base and one can start testing ansible. To connect to a different device then you have to use “Ping module”. This can be used as a simple connection test.
Ansible - m ping all
Q: Can you build your own modules with Ansible?
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.
Q: How can you find information in Ansible?
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.
Q: What does Fact mean in Ansible?
The term “Facts” is commonly used in Ansible environment. They are described in the playbooks areas where it displays known and discovered variables about the system. Facts are used to implement conditionals executions and also used for getting ad-hoc information of the information.
You can see all the facts via:
$ ansible all- m setup
So if you want to extract only certain part of the information then you can use “setup” module where you will have an option to filter out the output and just get hold of the fact that you are in need of.
Q: What is ask_pass in ansible?
The ask_pass is a control in Ansible Playbook.
This controls whether ansible playbook to prompt a password by default. Usually, the default behavior is no:
It is always set to ask_pass=True
If you are using SSH keys for authentication purposes then you really don’t have to change this setting at all.
Q: Explain What is ask_sudo_pass
This control is very similar to ask_pass
The ask_sudo_pass controls the Ansible Playbook to prompt a sudo password. Usually, the default behavior is no:
One has to make sure and change this setting where the sudo passwords are enabled most of the time.
Q: Explain what is ask_vault_pass?
Using this control we can determine whether Ansible Playbook should prompt a password for the vault password by default. As usual, the default behavior is no
Q: Explain Callback_plugin in Ansible?
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.
Q: Explain Module utilities in Ansible?
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.
Q: Where is the unit testing is available in Ansible?
Unit tests for all the modules are available in .test/units/modules.
Firstly you have to setup your testing environment
Q: Explain in detail about ad-hoc command?
Well, ad-hoc commands is nothing but a command which is used to do something quickly and it is more sort of a one-time use. Unlike, the playbook is used for a repeated actions which is something that is very useful in Ansible environment. But there might be scenarios where we want to use ad-hoc commands which can simply do the required activity and it is a nonrepetitive activity.
Get Updates on Tech posts, Interview & Certification questions and training schedules