Ansible Interview Questions & Answers |
Ansible Interview Questions & Answers
1. What is Configuration Management?
Ans-Configuration management defines the product and the configuration it provides the status and information about the product and its configuration documents.
2. How does Ansible work?
Ans-It operates by commanding devices and nodes and disseminating tiny programs known as modules.
It connects to servers and performs activities using the SSH protocol.
Controlling computers connect to distant machines using SSH keys and ssh-agent.
3. What are the features of Ansible?
Ans- Some of the Features are Following:-
(a) Aggentless
(b) Python
(C) ssh
(d) Push Architecture
(e) Manage inventory
4. Explain Infrastructure as Code?
Ans- Infrastructure as a code IaC is a process that DevOps teams follow to have a more organized way of managing the infrastructure.
5. What is Ansible Galaxy?
Ans- Ansible Galaxy is a repository of Ansible Roles it can be used by users for the execution of playbooks. It is used for the distribution of packages, plugins, and modules. It is a collection of commands like init, builds, installs.
6. what are the Ansible modules?
Ans- Core Module
Extras Modules
7. What is a YAML file in Ansible?
Ans- YAML syntax is for writing Ansible Playbook. Ansible uses YAML because it is easy to understand.
The Data is represented in YAML are-
(a) key-value pair
--
A student record
Karan:
name: Karan
roll no: 1
class: 11th
div: B
--
(b) Representing List
---
countries:
- India
- Africa
- Pakistan
- China
…
(c) Abbreviation
Karan: {name: Karan Abhi, rollNo:4, div: A, sex: male}
(d) List inside Dictionaries
---
Karan:
name: Karan Abhi
rollNo: 4
div: A
sex: male
likes:
- English
- Linux
- Bash
…
8. What are Ansible tasks?
Ans- Ansible code is written in the playbook, in which the user wants to execute code. This execution of code is known as the Ansible task.
install<package_name>,update <software_name>
9. What are callback plugins in Ansible?
Ans- It is a plugin that controls the output. for example log_plays callback is used to record playbook events and mail callback is used to send an email on the playbook.
10. What are the Ansible Inventory and its types?
Ans- There are two types of inventory
Static Inventory- The files are managed as a host which is declared under a host group using their hostname or IP address.
Dynamic Inventory- It is generated by a script that uses plugins and python programming languages.
11. explain Ansible Vault?
Ans- It is used to keep secret and sensitive data like passwords.
example Ansible-vault encrypt index.txt
Ansible-vault decrypt index.txt
12. How looping to be done over a list of hosts in a group, inside of a template?
Ans-{% for host in groups['db_servers']%}
{{host}}
{%endfor%}
16. What is the ad-hoc command in Ansible?
Ans- It is simple one-line commands which are used to perform tasks.
ansible <hosts> [-m <module_name>] -a <"arguments"> -u <username> [--become]
17. How to Install Nginx using Ansible playbook?
Ans----
- name: Install nginx
hosts: host.name.ip
become: true
tasks:
- name: Add epel-release repo
yum:
name: epel-release
state: present
- name: Install nginx
yum:
name: nginx
state: present
- name: Insert Index Page
template:
src: index.html
dest: /usr/share/nginx/html/index.html
- name: Start NGiNX
service:
name: nginx
state: started