Ansible Interview Questions and Answers | Ansible Interview Questions and Answers for Experienced | Ansible Interview Questions and Answers for Experienced Scenario Based | Mock Practice Ansible Interview Questions and Answers
Ansible Interview Questions and Answers | Ansible Interview Questions and Answers for Experienced | Ansible Interview Questions and Answers for Experienced Scenario Based
This is part -1 of Ansible Interview Questions and Answers
1. How does Ansible ensure idempotency in playbooks?
Answer: Ansible ensures idempotency by checking the state of resources before performing any changes. It uses modules that detect if the system is already in the desired state. If the target is already compliant with the desired configuration, no changes are made. This prevents the repeated execution of tasks, keeping the system stable and consistent.
2. What are Ansible Pull and Ansible Push modes, and when would you use each?
Answer:
Ansible Push is the default mode, where the control node pushes configurations to the managed nodes. It is useful when the control node has access to all managed nodes and the operations need to be triggered centrally.
Ansible Pull allows managed nodes to pull configurations from a centralized Git repository. This is used in scenarios where managed nodes might not be accessible from the control node due to network restrictions or security policies.
3. Can you explain Ansible Vault and how it enhances security in playbooks?
Answer: Ansible Vault is a feature that allows users to encrypt sensitive data like passwords, certificates, and other credentials. This encrypted data can be stored within playbooks and variables, ensuring secure handling of sensitive information. It uses AES-256 encryption, and the encrypted files can only be decrypted by providing the correct password or secret key when executing the playbook.
4. How do you manage large Ansible projects efficiently?
Answer: Large Ansible projects are managed by:
Using Roles to break down complex playbooks into reusable components.
Organizing the project directory structure based on roles, inventories, group_vars, host_vars, and other subdirectories.
Utilizing Dynamic Inventory for large-scale deployments to avoid manual updates.
Implementing Ansible Tower/AWX for better orchestration, role-based access control, and logging.
5. What are Dynamic Inventories, and how do they differ from Static Inventories?
Answer:
Static Inventories are lists of servers and groups defined manually in a file.
Dynamic Inventories are scripts or APIs that generate the list of hosts dynamically at runtime from cloud platforms, databases, or other external data sources. They allow for flexibility in environments where the infrastructure is elastic, such as in cloud environments (AWS, GCP, etc.).
#ansible #devops #docker #kubernetes #java #javascript #golang #codinginterview #programming #terraform #git #github #aws #azure #gcp #cloudcomputing #linux #admin #server #servers #storage #virtualization