Ansible Interview Prep: Key Questions u0026 Scenarios Quiz Quiz

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.

  1. Understanding Ansible's Control Node

    Which machine in an Ansible environment is responsible for running playbooks and managing other systems?

    1. Worker node
    2. Target node
    3. Control node
    4. Managed node

    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.

  2. Ansible Inventory File Basics

    What is the main role of the inventory file in Ansible?

    1. Storing module code
    2. Defining managed hosts
    3. Holding variables only
    4. Running playbooks

    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.

  3. YAML Syntax in Ansible

    Which symbol must be used at the beginning of every Ansible playbook file written in YAML?

    1. //
    2. u003Cu003Cu003C
    3. ---
    4. ###

    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.

  4. Ad-Hoc Commands Purpose

    If you want to quickly check the uptime of all servers in your inventory without writing a playbook, which Ansible feature should you use?

    1. Tasks list
    2. Handlers
    3. Roles
    4. Ad-hoc commands

    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.

  5. Idempotence in Ansible

    Which property describes Ansible’s ability to ensure multiple runs of the same playbook produce the same results on systems?

    1. Inherence
    2. Impudence
    3. Independence
    4. Idempotence

    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.

  6. Default Connection Protocol

    What is the default protocol Ansible uses to communicate with managed Linux hosts?

    1. FTP
    2. Telnet
    3. HTTP
    4. SSH

    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.

  7. Ansible Modules Usage

    Suppose you want to install software packages using Ansible. Which of the following best represents the component responsible for this?

    1. Playbook variables
    2. Inventory group
    3. Modules
    4. Vault

    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.

  8. Purpose of Handlers

    In an Ansible playbook, what is the main purpose of a handler with the 'notify' statement?

    1. Provide variable defaults
    2. Group several tasks
    3. Trigger actions only when changes occur
    4. Store sensitive data

    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.

  9. Conditional Execution

    How can you make a specific task in your Ansible playbook run only when a variable is true?

    1. Add a when statement
    2. Use a handler
    3. Run as ad-hoc command
    4. Specify an include

    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.

  10. Encrypting Sensitive Data

    Which Ansible feature should you use to keep passwords and sensitive variables secure inside playbooks?

    1. Role
    2. Inventory
    3. Vault
    4. Module

    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.