Find Interview Questions for Top Companies
Ques:- . What’s the difference between include and import in Ansible?
Right Answer:

In Ansible, `include` is used to include a file dynamically during playbook execution, allowing for conditional inclusion, while `import` is used to statically include a file at the time of playbook parsing, meaning it is always included regardless of conditions.

Ques:- What is idempotency in Ansible? Idempotency means running a playbook multiple times produces the same result (no changes unless necessary).
Right Answer:

Idempotency in Ansible means that running a playbook multiple times will produce the same result each time, with no changes made unless there is a need to update the system.

Ques:- How can you test Ansible playbooks locally? Use localhost in the inventory or run with connection: local.
Right Answer:

You can test Ansible playbooks locally by using `localhost` in your inventory file or by specifying `connection: local` in your playbook.

Ques:- What are callbacks in Ansible? Callbacks are plugins that enable custom output formats or logging (e.g., sending output to Slack).
Right Answer:

Callbacks in Ansible are plugins that allow you to customize the output format or logging of Ansible runs, such as sending notifications to Slack or formatting the output in a specific way.

Ques:- How do you include another playbook in your playbook? Using include or import_playbook directives.
Right Answer:

You can include another playbook in your playbook using the `import_playbook` directive.

Ques:-  What is a handler in Ansible? Handlers are tasks that run only when notified (e.g., restart a service after config change).
Right Answer:

A handler in Ansible is a special type of task that runs only when it is notified by another task, typically used to perform actions like restarting a service after a configuration change.

Ques:- How do you run only one task from a playbook? Using –start-at-task=”task name” or –tags with a specific tag.
Right Answer:

You can run only one task from a playbook using `–start-at-task="task name"` or by using `–tags` with a specific tag assigned to that task.

Ques:- What is the difference between “shell” and “command” modules?
Right Answer:

The "shell" module allows you to run shell commands and supports shell features like pipes and redirection, while the "command" module runs commands without a shell, so it does not support shell features.

Ques:-  How can you encrypt sensitive data in Ansible? Using Ansible Vault to encrypt passwords, secrets, and files.
Right Answer:

You can encrypt sensitive data in Ansible using Ansible Vault by running the command `ansible-vault encrypt <file>` to encrypt files or `ansible-vault encrypt_string '<string>'` to encrypt individual strings.

Ques:- What is the difference between vars, defaults, and environment variables in Ansible?
Right Answer:

In Ansible:

– **vars**: These are variables defined in a playbook or role that can be used throughout the playbook. They have the highest precedence.
– **defaults**: These are default variables defined in a role's `defaults/main.yml` file. They have lower precedence than regular vars and are overridden by them.
– **environment variables**: These are variables set in the environment where Ansible runs. They can be accessed in playbooks but have the lowest precedence compared to vars and defaults.

Ques:- What are Ansible facts? Facts are system information (like IP, OS, memory, etc.) collected by Ansible from the remote nodes using the setup module.
Right Answer:

Ansible facts are system information collected from remote nodes, such as IP address, operating system, memory, and more, using the setup module.

Ques:- How does Ansible work?
Right Answer:

Ansible works by using a push-based model to automate tasks on remote systems. It connects to target machines over SSH (or WinRM for Windows) and executes modules, which are small programs that perform specific tasks. Ansible uses playbooks, written in YAML, to define the desired state of the systems and the steps needed to achieve that state. It does not require an agent to be installed on the target machines, making it lightweight and easy to use.

Ques:- What is Ansible?
Asked In :-
Right Answer:

Ansible is an open-source automation tool used for configuration management, application deployment, and task automation, allowing users to manage systems and applications in a simple and efficient way using playbooks written in YAML.



AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users