EX294 Practice Question: Create content collections and execution environments
Which command publishes a collection to Automation Hub?
⚠ Common exam trap
Watch out — candidates often confuse the `ansible-galaxy role push` command (used for roles) with the collection workflow, mistakenly assuming 'push' or 'upload' are valid for collections, when only `publish` is correct.
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-galaxy collection publish ./namespace-name-1.0.0.tar.gz --token MYTOKEN
`ansible-galaxy collection publish` is the specific command used to upload a collection tarball to Automation Hub (or any Galaxy server). The `--token` flag provides the required API authentication token for the publish operation. This command sends the tarball to the server's API endpoint, which validates and imports the collection.
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-galaxy collection import ./namespace-name-1.0.0.tar.gz
Why it's wrong here
'import' is used for importing collections from a source, not publishing.
- ✗
ansible-galaxy collection upload ./namespace-name-1.0.0.tar.gz
Why it's wrong here
The correct command is 'publish', not 'upload'.
- ✗
ansible-galaxy collection push ./namespace-name-1.0.0.tar.gz
Why it's wrong here
The `ansible-galaxy collection push` subcommand does not exist; the CLI offers `publish` for uploading a built tarball to Automation Hub. Push is tempting because it mirrors `git push`, and the verb feels natural for transferring artefacts. Publishing to a private Automation Hub or Galaxy server would be the correct scenario, using `ansible-galaxy collection publish`.
- ✓
ansible-galaxy collection publish ./namespace-name-1.0.0.tar.gz --token MYTOKEN
Why this is correct
The ansible-galaxy collection publish subcommand uploads the built tarball to Automation Hub, authenticating with the API token via --token. This satisfies the requirement to push a collection artefact to the Hub, since the tarball must already exist before publishing.
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 →
Same concept, more angles
2 more ways this is tested on EX294
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A developer has created a collection and needs to publish it to a private Automation Hub. Which command should be used to upload the collection archive?
easy- A.`ansible-galaxy collection server upload ./tar.gz`
- ✓ B.`ansible-galaxy collection publish ./my-namespace-my_collection-1.0.0.tar.gz`
- C.`ansible-galaxy role import my-namespace my_collection`
- D.`ansible-galaxy collection upload ./my-namespace-my_collection-1.0.0.tar.gz`
Why B: The correct command to upload a collection archive to a private Automation Hub is `ansible-galaxy collection publish ./my-namespace-my_collection-1.0.0.tar.gz`. This command authenticates to the configured Automation Hub server (as defined in `ansible.cfg` or the `--server` flag) and publishes the tarball, making it available for other users to install. The `publish` subcommand is specifically designed for this purpose, handling the API call to the Galaxy or Automation Hub server.
Variation 2. An organization uses a private automation hub to distribute collections. A developer has created a new collection and needs to ensure it is available in the hub for others. Which command should the developer use to upload the collection to the private automation hub?
medium- A.ansible-galaxy collection import
- B.ansible-galaxy collection build
- ✓ C.ansible-galaxy collection publish
- D.ansible-galaxy collection install
Why C: `ansible-galaxy collection publish` is the command specifically designed to upload a built collection artifact (a .tar.gz file) to a Galaxy server, including a private automation hub. This command sends the collection to the configured Galaxy server endpoint, making it available for others to install via `ansible-galaxy collection install`.
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.