Courseiva

EX294 Manage inventories and credentials Practice Question

An administrator maintains a dynamic inventory script that outputs JSON. The script is placed at `/etc/ansible/inventory/aws_inventory.py` and is executable. The administrator runs `ansible-playbook -i /etc/ansible/inventory/aws_inventory.py site.yml` but receives an error: "Unable to parse /etc/ansible/inventory/aws_inventory.py as an inventory source". Which action is most likely to resolve the issue?

⚠ Common exam trap

The trap here is assuming that file extension or configuration location determines dynamic inventory parsing, when the critical factor is the script's executable behavior and JSON output for --list.

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

✓

Ensure the script outputs a JSON object with a top-level key `_meta` containing `hostvars`, and that the script supports the `--list` argument.

Dynamic inventory scripts must be executable and support the --list argument, returning valid JSON with groups and hosts. The _meta key with hostvars is recommended to avoid separate --host calls. The parse error typically occurs when the script fails to output valid JSON or does not handle --list. The other options either misrepresent how Ansible detects dynamic inventories or take actions that would not fix the script's output.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Ensure the script outputs a JSON object with a top-level key `_meta` containing `hostvars`, and that the script supports the `--list` argument.

    Why this is correct

    Ansible dynamic inventory scripts must accept the --list argument and output JSON with groups and hosts. The _meta key is optional but recommended to provide hostvars efficiently. If the script does not support --list or outputs invalid JSON, Ansible cannot parse it. This is the most common cause of the parse error. Ensuring the script meets these requirements resolves the issue.

  • ✗

    Change the script's file extension to .json so Ansible recognizes it as a JSON inventory.

    Why it's wrong here

    Ansible does not rely on file extensions to determine inventory type. It checks if the file is executable and attempts to run it with --list. Renaming to .json would make Ansible treat it as a static JSON file, which would fail unless the content is valid static JSON. This does not address the dynamic script requirements and likely worsens the problem.

  • ✗

    Make the script non-executable and pass it as a static inventory file.

    Why it's wrong here

    Dynamic inventory scripts must be executable; Ansible runs them to get inventory data. Making it non-executable would cause Ansible to try to read it as a static file, which would fail because it is a script, not an INI or YAML inventory. This action directly contradicts the requirement for dynamic scripts and would not resolve the parse error.

  • ✗

    Add the script path to the `inventory` setting in ansible.cfg and remove the -i option from the command.

    Why it's wrong here

    Specifying the inventory in ansible.cfg is a valid configuration method, but removing -i does not fix the underlying parse error. The error indicates the script itself is not producing valid output or not handling --list. Changing how it is specified does not correct the script's behavior. The problem would persist as long as the script is malformed.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

Courseiva writes every EX294 question from scratch — 392 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.