EX294 Practice Question: Create content collections and execution environments
You are developing a content collection and need to include a custom Ansible module that requires a specific Python library. The library is not available as a system package and must be installed via pip. Where should you declare this Python dependency so that it is automatically installed when the collection is used in an execution environment?
⚠ Common exam trap
The trap here is assuming that Python dependencies for a collection can be declared in galaxy.yml or requirements.txt, when in fact the execution environment definition is the correct place for build-time installation.
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
✓
In the execution-environment.yml file under the dependencies section with the python option.
When building an execution environment, Python dependencies can be declared in the execution-environment.yml file under the dependencies section with the python key. This instructs ansible-builder to install the specified Python packages via pip into the execution environment, making them available to modules and plugins that require them.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
In the galaxy.yml file under the dependencies key, specifying the Python package name.
Why it's wrong here
The galaxy.yml file's dependencies key is used to list other Ansible collections that this collection depends on, not Python packages. It expects collection names in the format namespace.collection. Python dependencies cannot be declared there, and attempting to do so would cause errors during collection installation.
- ✗
In the module file itself, using a try/except ImportError block to install the library at runtime.
Why it's wrong here
While you can attempt to install a library at runtime within a module, this is not recommended and often fails due to permission restrictions or lack of network access. The proper approach is to declare the dependency so it is installed during the execution environment build, ensuring the library is available when the module runs.
- ✗
In the requirements.txt file within the collection root.
Why it's wrong here
A requirements.txt file in the collection root is not automatically processed by ansible-builder or ansible-galaxy. While you can manually include it, the standard way to declare Python dependencies for a collection in an execution environment is through the execution-environment.yml file or the collection's meta/requirements.txt, but the latter is not automatically installed by ansible-builder unless specified.
- ✓
In the execution-environment.yml file under the dependencies section with the python option.
Why this is correct
The execution-environment.yml file allows you to specify Python packages under the dependencies section using the python key. This tells ansible-builder to install those packages via pip during the execution environment build. This is the correct place to declare Python library dependencies for collections used in the execution environment.
Go deeper
Related to this question
About these practice questions
This EX294 question is part of Courseiva's 392-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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Red Hat exam blueprint
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.