Ansible for Cloud Automation: AWS, Azure, GCP Fundamentals Quiz Quiz

Explore key concepts and practical scenarios in using Ansible for automating cloud infrastructure across AWS, Azure, and GCP. Assess your foundational understanding of configuration management, cloud modules, and best practices for multi-cloud automation using Ansible.

  1. Ansible Inventory Usage

    Which type of inventory allows Ansible to dynamically discover cloud resources such as instances or virtual machines for automation tasks?

    1. Dynamic inventory
    2. Manual inventory
    3. Host inventory
    4. Static inventory

    Explanation: Dynamic inventory automatically retrieves information about current cloud resources, making it suitable for environments where infrastructure changes frequently. Static inventory, on the other hand, requires manually listing resources, which can become outdated quickly. Manual inventory is not a recognized Ansible concept. Host inventory simply refers to listing hosts, without dynamic capabilities.

  2. Provisioning Virtual Machines

    When automating the creation of a virtual machine in a cloud environment using Ansible, which module type should you use?

    1. File modules
    2. Copy modules
    3. Shell modules
    4. Cloud-specific modules

    Explanation: Cloud-specific modules are designed to interact with cloud providers' APIs to manage resources like virtual machines. File and copy modules are used for file management on remote servers, not resource provisioning. Shell modules execute shell commands but are not tailored for structured cloud automation.

  3. Credential Management

    What is a secure way to manage sensitive access keys or credentials required for running Ansible playbooks against cloud platforms?

    1. Store credentials directly in playbooks
    2. Save secrets in plain text on the server
    3. Use Ansible Vault to encrypt secrets
    4. Share access keys in public repositories

    Explanation: Ansible Vault provides encryption to protect sensitive data such as credentials, ensuring increased security. Storing credentials in playbooks or in plain text exposes them to unauthorized access, while sharing access keys in public repositories is highly insecure and never recommended.

  4. Cloud Tagging Automation

    How can Ansible playbooks help enforce consistent tagging on cloud resources during deployment?

    1. Avoid using tags in automation
    2. Add tags manually after creating resources
    3. Rely on default system tags only
    4. Include tag parameters in resource creation tasks

    Explanation: Specifying tag parameters directly in Ansible tasks ensures tags are applied automatically and consistently as resources are deployed. Adding tags manually increases the risk of human error. Relying solely on default tags means important contextual information may be missing. Avoiding tags undermines resource management and cost tracking.

  5. Resource Idempotency

    What does it mean for an Ansible cloud automation task to be idempotent?

    1. It randomly creates and deletes resources
    2. It produces the same result no matter how many times it is run
    3. It scales servers on every run
    4. It requires manual confirmation each time

    Explanation: Idempotent tasks ensure the infrastructure remains in the desired state, even with repeated executions, which is essential for predictable automation. Scaling servers on every run can lead to resource waste. Randomly creating or deleting resources is unpredictable. Manual confirmation negates automation efficiency.

  6. Multi-Cloud Inventory Differentiation

    In a scenario where both AWS and Azure resources are managed with Ansible, what is a simple way to differentiate these resources in your inventory?

    1. List all resources under a single group
    2. Use inventory groups based on cloud provider
    3. Assign duplicate hostnames
    4. Omit group names

    Explanation: Grouping resources by provider allows tailored playbooks or variables, making management easier and organized. Listing all resources in one group loses clarity. Omitting groups provides no structure. Assigning duplicate hostnames can cause confusion and errors during automation runs.

  7. Playbook Cloud Error Handling

    If a cloud resource fails to create during a playbook run, which Ansible directive helps you gracefully handle the error?

    1. ignore_errors: yes
    2. skip_if_failed: yes
    3. continue_on_fail: true
    4. pass_on_error: enabled

    Explanation: ignore_errors: yes instructs Ansible to continue with the next tasks even if the current one fails. continue_on_fail and pass_on_error are not valid Ansible parameters. skip_if_failed: yes does not exist in Ansible documentation.

  8. Cloud Resource Facts Gathering

    Which module allows Ansible to collect information about cloud resources, such as instance attributes, for use in later tasks?

    1. User module
    2. Wait_for module
    3. Facts module
    4. Ping module

    Explanation: The facts module collects detailed information about cloud resources, which can be referenced in subsequent tasks. The ping module checks connectivity. The user module manages user accounts. The wait_for module waits for conditions but does not gather detailed resource data.

  9. Cross-Cloud Variable Management

    When writing playbooks for multiple cloud providers, how can you avoid hard-coding values specific to each environment?

    1. Use variables and group_vars for each provider
    2. Embed provider names in every task
    3. Ignore environment differences
    4. Write separate playbooks for each provider

    Explanation: By defining variables and using group_vars, you centralize and simplify configurations for each environment. Writing separate playbooks increases maintenance. Embedding provider names in every task reduces flexibility. Ignoring environment differences leads to errors and failures in automation.

  10. Infrastructure as Code Concept

    What best describes the 'infrastructure as code' approach enabled by Ansible for cloud environments?

    1. Manually configuring resources via dashboards
    2. Automating infrastructure deployment through code-like configurations
    3. Storing documentation in code files
    4. Automating only software installation

    Explanation: Infrastructure as code means using declarative or script-based files for creating and managing infrastructure, ensuring consistency and repeatability. Manual configuration misses the automation, speed, and reliability. Automating only software installation focuses on post-provisioning, not infrastructure. Documentation alone does not automate infrastructure.