Top 50 Ansible Interview Question.

Here are the answers to the top 50 Ansible interview questions:

  1. What is Ansible?

    • Ansible is an open-source automation tool used for configuration management, application deployment, and task automation.
  2. What are the advantages of using Ansible?

    • Simple to set up and use
    • Agentless architecture
    • Idempotent operations
    • Strong community support
  3. How does Ansible work?

    • Ansible uses SSH for communication and YAML for configuration. It executes tasks on remote systems using modules.
  4. What is an Ansible playbook?

    • A playbook is a YAML file containing a series of tasks to be executed on remote hosts.
  5. What is an inventory file in Ansible?

    • An inventory file lists the hosts and groups of hosts on which Ansible commands, modules, and playbooks operate.
  6. Explain the architecture of Ansible.

    • Ansible architecture includes modules, plugins, inventories, playbooks, and the Ansible command-line tool.
  7. What are Ansible modules?

    • Modules are reusable, standalone scripts that Ansible runs on your behalf. Examples include copy, yum, and service.
  8. How do you install Ansible?

    • You can install Ansible using package managers like pip, apt, or yum.
  9. What is the use of Ansible Galaxy?

    • Ansible Galaxy is a repository for Ansible roles, allowing users to share and download roles.
  10. How do you create a new role in Ansible?

    • Use the command ansible-galaxy init <role_name> to create a new role directory structure.
  11. What is the difference between a playbook and a role in Ansible?

    • A playbook is a collection of tasks, while a role is a way to organize playbooks and other files into reusable components.
  12. How do you handle errors in Ansible?

    • Use the ignore_errors directive or the failed_when condition to handle errors.
  13. What is Ansible Tower?

    • Ansible Tower is an enterprise framework for controlling, securing, and managing your Ansible automation with a UI and REST API.
  14. How do you manage variables in Ansible?

    • Variables can be managed in playbooks, inventory files, or variable files.
  15. What is a task in Ansible?

    • A task is a single unit of work to be executed on a host, defined in a playbook.
  16. How do you use loops in Ansible?

    • Use the with_items directive to loop over a list of items.
  17. What is a handler in Ansible?

    • A handler is a task that runs only when notified by another task.
  18. How do you use conditionals in Ansible?

    • Use the when directive to execute tasks conditionally.
  19. What is the purpose of the ansible.cfg file?

    • The ansible.cfg file is used to configure Ansible settings.
  20. How do you secure sensitive data in Ansible?

    • Use ansible-vault to encrypt sensitive data.
  21. What is the difference between command and shell modules in Ansible?

    • The command module executes commands without a shell, while the shell module executes commands through a shell.
  22. How do you use tags in Ansible?

    • Tags are used to run specific tasks or plays in a playbook.
  23. What is the use of the debug module in Ansible?

    • The debug module prints statements during playbook execution for debugging purposes.
  24. How do you run a specific task in Ansible?

    • Use tags and the --tags or --skip-tags options to run specific tasks.
  25. What is the ansible-vault command used for?

    • ansible-vault is used to encrypt and decrypt sensitive data.
  26. How do you use templates in Ansible?

    • Use the template module to process Jinja2 templates and copy them to remote hosts.
  27. What is the difference between include and import in Ansible?

    • include is dynamic and evaluated at runtime, while import is static and evaluated at parse time.
  28. How do you manage dependencies in Ansible?

    • Use roles and the dependencies key in meta/main.yml to manage dependencies.
  29. What is the ansible-pull command?

    • ansible-pull is used to pull playbooks from a VCS repository and execute them on the local machine.
  30. How do you use the copy module in Ansible?

    • The copy module copies files from the local machine to remote hosts.
  31. What is the lineinfile module used for?

    • The lineinfile module ensures a particular line is present or absent in a file.
  32. How do you use the file module in Ansible?

    • The file module manages file properties like permissions, ownership, and symlinks.
  33. What is the yum module used for?

    • The yum module manages packages on RPM-based systems.
  34. How do you use the service module in Ansible?

    • The service module manages services on remote hosts.
  35. What is the user module used for?

    • The user module manages user accounts on remote hosts.
  36. How do you use the cron module in Ansible?

    • The cron module manages cron jobs on remote hosts.
  37. What is the git module used for?

    • The git module manages Git repositories.
  38. How do you use the synchronize module in Ansible?

    • The synchronize module is a wrapper around rsync to synchronize files between hosts.
  39. What is the wait_for module used for?

    • The wait_for module waits for a condition to be met before proceeding.
  40. How do you use the uri module in Ansible?

    • The uri module interacts with web services.
  41. What is the setup module used for?

    • The setup module gathers facts about remote hosts.
  42. How do you use the command module in Ansible?

    • The command module runs commands on remote hosts.
  43. What is the shell module used for?

    • The shell module runs shell commands on remote hosts.
  44. How do you use the raw module in Ansible?

    • The raw module runs raw commands on remote hosts without any processing.
  45. What is the script module used for?

    • The script module runs scripts on remote hosts.
  46. How do you use the win_command module in Ansible?

    • The win_command module runs commands on Windows hosts.
  47. What is the win_shell module used for?

    • The win_shell module runs shell commands on Windows hosts.
  48. How do you use the win_copy module in Ansible?

    • The win_copy module copies files to Windows hosts.
  49. What is the win_service module used for?

    • The win_service module manages services on Windows hosts.
  50. How do you use the win_user module in Ansible?

    • The win_user module manages user accounts on Windows hosts.

I hope this helps with your interview preparation! If you need further details on any of these topics, feel free to ask. Good luck!

Comments

Popular posts from this blog

Clearing DNS cache on vCenter Server Appliance

Repairing a virtual disk in Workstation (2019259)