Ansible Automation Technology & Digital Applications 4 — Questions and Answers
Question 1: What is the purpose of the 'register' keyword combined with 'until' in Ansible?
- Retries a task until the registered output meets a condition (Correct answer)
- Registers a variable permanently across playbooks
- Loops through tasks until a counter is reached
- Stores output until the playbook ends
Correct answer: Retries a task until the registered output meets a condition
Combining register with until, retries, and delay creates a polling loop that retries a task until the captured output satisfies a specified condition.
Question 2: In Ansible automation for cloud environments, what does 'infrastructure as code' mean in practice?
- Defining and managing cloud resources through versioned playbooks and templates (Correct answer)
- Writing Python scripts to call cloud APIs directly
- Using cloud provider GUIs with exported JSON
- Manually provisioning servers and documenting steps
Correct answer: Defining and managing cloud resources through versioned playbooks and templates
Infrastructure as code with Ansible means cloud resources are defined in playbooks stored in version control, enabling repeatable, auditable provisioning.
Question 3: Which Ansible module enables idempotent management of cron jobs on Linux systems?
- ansible.builtin.cron (Correct answer)
- crontab_manage
- schedule_task
- linux.cron
Correct answer: ansible.builtin.cron
The ansible.builtin.cron module adds, modifies, or removes cron jobs idempotently, ensuring the desired state is applied without duplication.
Question 4: What does Ansible's 'check mode' (--check) do differently from a normal run?
- Simulates changes and reports what would happen without making actual modifications (Correct answer)
- Checks connectivity to all hosts before running
- Validates module parameters against documentation
- Runs tasks only on a subset of hosts for testing
Correct answer: Simulates changes and reports what would happen without making actual modifications
Check mode (dry run) causes Ansible to report what changes it would make without actually executing them on the remote systems.
Question 5: When automating patch management with Ansible, which approach ensures minimal downtime for web servers?
- Use serial with load balancer module to drain and patch nodes one at a time (Correct answer)
- Run all patches simultaneously across the fleet
- Patch during peak hours to verify stability
- Only patch servers manually after Ansible reports findings
Correct answer: Use serial with load balancer module to drain and patch nodes one at a time
Combining the serial keyword with load balancer modules (like bigip_pool_member) drains traffic from each node before patching, ensuring continuous availability.
Question 6: What is the role of Ansible Collections in modern automation workflows?
- Package and distribute modules, roles, plugins, and playbooks as a versioned unit (Correct answer)
- Replace playbooks entirely with a new format
- Store only third-party modules separate from core
- Provide a GUI for managing Ansible content
Correct answer: Package and distribute modules, roles, plugins, and playbooks as a versioned unit
Collections are the standard distribution format that bundles related Ansible content (modules, roles, plugins) and enables semantic versioning for dependency management.
Question 7: Which Ansible feature allows you to define environment-specific variables without modifying the playbook?
- Group vars and host vars directories (Correct answer)
- Hardcoded variables in the playbook
- Separate playbooks per environment
- Environment-specific module parameters
Correct answer: Group vars and host vars directories
The group_vars and host_vars directories allow environment-specific variables to be stored outside the playbook, making playbooks reusable across environments.
What is the purpose of the 'register' keyword combined with 'until' in Ansible?