EX294 Implement advanced Ansible automation Practice Question
An Ansible playbook fails intermittently when deploying web servers. The error message indicates that a required package is not available in the repository. Which approach would best ensure that the required packages are consistently available before the playbook runs?
⚠ Common exam trap
It's easy for candidates to choose retries (Option B) thinking it handles transient network issues, but the real problem is a stale metadata cache, which retries cannot fix; the exam tests understanding of package manager internals versus generic error-handling strategies.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Add a pre_task to run 'dnf update' or 'apt update' before the package installation.
The intermittent failure is caused by the package metadata cache being stale or missing. Running 'dnf update' (RHEL/CentOS) or 'apt update' (Debian/Ubuntu) as a pre_task refreshes the repository index, ensuring that the package manager has the latest list of available packages before attempting installation. This directly resolves the 'package not available' error by synchronizing the local cache with the remote repository.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set 'ignore_errors: yes' on the package installation task and handle the failure later.
Why it's wrong here
Ignoring errors can lead to an inconsistent system state.
- ✗
Add retries and delay to the package installation task.
Why it's wrong here
Retries only help with transient failures, not with permanently missing packages.
- ✓
Add a pre_task to run 'dnf update' or 'apt update' before the package installation.
Why this is correct
Updating the repository cache ensures the latest package metadata is available.
- ✗
Use the 'get_url' module to download the package from an external source and install it manually.
Why it's wrong here
While possible, it adds complexity and may not be a best practice.
Visual reference
Go deeper
Related to this question
About these practice questions
This EX294 question is part of Courseiva's 520-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This EX294 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX294 exam.