Definitions
Hereβs a complete list of Ansible concepts, components, and objects with definitions. This will cover everything an interviewer might ask.
1. Core Concepts in Ansible
1.1. Ansible
An open-source configuration management, automation, and orchestration tool used to provision and manage infrastructure declaratively.
1.2. Agentless
Ansible does not require agents on managed nodes. It uses SSH for Linux and WinRM for Windows.
1.3. Idempotency
Ensures that running the same Ansible playbook multiple times produces the same result without unintended changes.
1.4. Push vs Pull Mode
Push Mode (default): The Ansible control node pushes configurations to target nodes.
Pull Mode: Managed nodes fetch configurations from a central repository (using
ansible-pull).
2. Key Components & Objects in Ansible
2.1. Inventory
A file that lists managed nodes (hosts) along with their IPs, groupings, and variables.
Default:
/etc/ansible/hostsFormats: INI, YAML, or Dynamic Inventory (AWS, Azure, GCP).
π Example (INI format)
2.2. Playbook
A YAML file containing tasks that define automation steps.
It contains plays that run sequentially on managed nodes.
π Example
2.3. Tasks
Individual units of work inside a playbook. They execute modules to perform specific actions (e.g., install a package, restart a service).
π Example
2.4. Modules
Reusable Ansible plugins that execute specific actions on nodes.
π Types of Modules:
System Modules:
service,apt,yum,firewalldFile Modules:
copy,file,fetch,templateCloud Modules:
ec2_instance,gcp_compute_instanceUser Modules:
user,group,hostname
π Example (Using copy module)
2.5. Roles
A structured way to organize Ansible playbooks into reusable components. Each role contains tasks, handlers, templates, and variables.
π Role Directory Structure
π Run a Role in Playbook
2.6. Handlers
Similar to tasks but only run when notified by another task. Commonly used for restarting services after configuration changes.
π Example
2.7. Variables
Allow parameterization in playbooks.
π Types of Variables:
Defined in Playbooks
Defined in Inventory
Facts (Gathered from Nodes)
External Variables (via
vars_files)
π Example
2.8. Templates (Jinja2)
Dynamic configuration files using Jinja2 templating.
π Example (nginx.conf.j2)
π Apply Template in Playbook
2.9. Facts
Automatically collected system information about managed nodes.
π Check facts manually
π Use a fact in a Playbook
2.10. Conditionals
Execute tasks based on conditions.
π Example
2.11. Loops
Run a task multiple times.
π Example (Looping through a list)
2.12. Tags
Run only specific parts of a playbook.
π Tagging a Task
π Run Playbook with a Specific Tag
2.13. Ansible Vault
Encrypts sensitive information (passwords, keys) in playbooks.
π Encrypt a file
π Use Vault in a Playbook
2.14. Ansible Galaxy
A community repository for Ansible roles.
π Install a Role from Galaxy
2.15. Ansible Pull
Used for agent-based Ansible deployments.
π Example
Conclusion
This covers all major Ansible concepts that interviewers typically ask.
Pro Tip π‘
π¬ Before the interview:
Revise key modules (
apt,yum,copy,template,service).Practice YAML syntax & playbooks.
Prepare real-world use cases from your experience.
Let me know if you need mock interview questions or playbook scenarios. π
Last updated