Courseiva

EX294 Manage inventories and credentials Practice Question

An automation engineer manages two data centers with Ansible Automation Platform 2.4. The production inventory file is located at /etc/ansible/prod_inventory.ini and the staging inventory at /etc/ansible/stage_inventory.ini. The engineer wants to run a playbook against both inventories in a single ansible-playbook command, but the host groups must remain separate so that group_vars/prod and group_vars/stage apply correctly. Which command should the engineer use?

⚠ Common exam trap

The trap here is assuming that a comma-separated list of files can be passed to a single -i option, when in fact -i must be repeated for each inventory source.

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

✓

ansible-playbook -i /etc/ansible/prod_inventory.ini -i /etc/ansible/stage_inventory.ini site.yml

Ansible supports multiple inventory sources by repeating the -i option. Each source is parsed separately and merged, preserving distinct group names so that group_vars directories are applied based on group membership. Using a single -i with a comma-separated list or additional positional arguments does not achieve the same result and will cause errors.

Answer analysis

Option-by-option breakdown

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

  • ✗

    ansible-playbook --inventory=/etc/ansible/prod_inventory.ini --inventory=/etc/ansible/stage_inventory.ini site.yml

    Why it's wrong here

    The long option --inventory does not exist; the correct long form is --inventory-file or --inventory, but in Ansible the accepted long option is --inventory-file (or just -i). Using --inventory causes the command to fail with an unrecognized option. Even if the option were valid, the short -i flag is the standard way to specify multiple sources.

  • ✗

    ansible-playbook -i /etc/ansible/prod_inventory.ini,/etc/ansible/stage_inventory.ini site.yml

    Why it's wrong here

    A comma-separated string passed to a single -i is treated as one inventory source, not as two files. Ansible will look for a file literally named 'prod_inventory.ini,/etc/ansible/stage_inventory.ini', which does not exist, and the run will fail with a parsing error. This syntax is used for inline host lists, not for multiple inventory files.

  • ✗

    ansible-playbook -i /etc/ansible/prod_inventory.ini /etc/ansible/stage_inventory.ini site.yml

    Why it's wrong here

    The second path is interpreted as the playbook argument, and site.yml becomes an extra positional argument. Ansible will attempt to execute the inventory file as a playbook, resulting in an error. Only one inventory source is provided via -i, so the staging hosts would not be included even if the argument order were corrected.

  • ✓

    ansible-playbook -i /etc/ansible/prod_inventory.ini -i /etc/ansible/stage_inventory.ini site.yml

    Why this is correct

    Multiple -i flags are supported by ansible-playbook; each inventory source is parsed independently and merged into a single inventory. Groups with the same name are combined, but distinct groups like prod and stage remain separate, so group_vars directories are applied correctly. This command meets the requirement without altering the inventory files.

About these practice questions

One of 392 original EX294 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.