Sharpen your basic Ansible knowledge with this easy quiz featuring essential interview questions, key concepts, and practical scenarios. Perfect for beginners preparing for interviews and seeking a solid understanding of Ansible automation tasks and playbook fundamentals.
Which machine in an Ansible environment is responsible for running playbooks and managing other systems?
Explanation: The control node is the central machine from which playbooks are run and other systems are managed. Managed nodes are the targets being configured, while worker node and target node are incorrect terms in Ansible context. Only the control node contains the necessary installation to execute Ansible commands.
What is the main role of the inventory file in Ansible?
Explanation: The inventory file's primary purpose is to define the list of managed hosts that Ansible will automate. While it can also include variables, its core role is not about storing variables alone. Module code is stored separately, and running playbooks is done via the command line, not the inventory file.
Which symbol must be used at the beginning of every Ansible playbook file written in YAML?
Explanation: In YAML files, including Ansible playbooks, the document start marker is three dashes (---). The use of //, u003Cu003Cu003C, or ### is not valid YAML syntax and would raise errors if placed at the start of a playbook.
If you want to quickly check the uptime of all servers in your inventory without writing a playbook, which Ansible feature should you use?
Explanation: Ad-hoc commands allow you to run quick, one-time Ansible tasks like checking uptime without creating a full playbook. Roles, handlers, and task lists are more structured and meant for reusable or organized automation rather than one-off commands.
Which property describes Ansible’s ability to ensure multiple runs of the same playbook produce the same results on systems?
Explanation: Idempotence means executing the same playbook repeatedly does not change the outcome after the first successful run, ensuring consistent state. Independence isn’t relevant to this context, while impudence and inherence are unrelated terms.
What is the default protocol Ansible uses to communicate with managed Linux hosts?
Explanation: By default, Ansible communicates with managed Linux systems using SSH, which is secure and standard. HTTP and FTP are not suitable or secure for command execution, and Telnet is less secure and not used by default.
Suppose you want to install software packages using Ansible. Which of the following best represents the component responsible for this?
Explanation: Ansible modules are reusable units of code, like package, user, or file, which perform specific tasks such as installing software. Vault is for encrypting variables, playbook variables store data but don’t perform actions, and inventory groups are used for organizing hosts.
In an Ansible playbook, what is the main purpose of a handler with the 'notify' statement?
Explanation: Handlers are triggered by tasks with a 'changed' status and only run when notified, ensuring efficient operation. Handlers do not store data, group tasks, or define variable defaults, which are handled elsewhere in Ansible.
How can you make a specific task in your Ansible playbook run only when a variable is true?
Explanation: The 'when' statement is used to add conditions to tasks, executing them only if a condition, such as a variable being true, is met. Handlers respond to notifications, includes are for importing, and ad-hoc commands are run separately from playbooks.
Which Ansible feature should you use to keep passwords and sensitive variables secure inside playbooks?
Explanation: Ansible Vault is designed to encrypt sensitive information such as passwords or keys. Roles and modules help organize and execute automation, while inventory stores host lists but does not handle encryption.