Ansible Automation Professional Standards & Competencies 4 — Questions and Answers
Question 1: A professional Ansible developer is asked to share a role with the broader community. Which platform and format is the industry standard?
- GitHub only, as a flat collection of YAML files
- Ansible Galaxy with a properly structured role following Galaxy metadata standards (Correct answer)
- Docker Hub as a container image
- A private PyPI package
Correct answer: Ansible Galaxy with a properly structured role following Galaxy metadata standards
Ansible Galaxy is the official hub for sharing Ansible roles and collections, requiring standard metadata in galaxy.yml or meta/main.yml.
Question 2: Which variable precedence rule is critical professional knowledge when debugging unexpected variable values in Ansible?
- Inventory variables always override everything else
- Extra vars (-e) have the highest precedence, overriding all other variable sources (Correct answer)
- Role defaults have the highest precedence
- Host vars and group vars share equal precedence
Correct answer: Extra vars (-e) have the highest precedence, overriding all other variable sources
Extra vars passed with -e at the command line have the highest precedence in Ansible's variable hierarchy.
Question 3: What is the professional standard for handling long-running tasks that may time out on the control node connection?
- Increase the SSH timeout indefinitely in ansible.cfg
- Use 'async' and 'poll' to run the task asynchronously and check its status separately (Correct answer)
- Split the task into smaller subtasks to avoid timeouts
- Use the 'raw' module which ignores timeouts
Correct answer: Use 'async' and 'poll' to run the task asynchronously and check its status separately
Async tasks with polling allow Ansible to start a long-running job, release the connection, and check back on completion.
Question 4: According to professional Ansible standards, what should be stored in 'defaults/main.yml' versus 'vars/main.yml' in a role?
- defaults holds computed variables; vars holds static ones
- defaults holds low-precedence variables meant to be overridden; vars holds high-precedence variables not intended to be changed (Correct answer)
- Both files serve the same purpose and are interchangeable
- defaults holds secrets; vars holds public variables
Correct answer: defaults holds low-precedence variables meant to be overridden; vars holds high-precedence variables not intended to be changed
defaults/main.yml provides overridable role defaults with the lowest variable precedence, while vars/main.yml holds fixed role internals with higher precedence.
Question 5: A professional engineer wants to validate a playbook syntax without executing it. Which command should they use?
- ansible-playbook site.yml --dry-run
- ansible-playbook site.yml --syntax-check (Correct answer)
- ansible-playbook site.yml --validate
- ansible site.yml --check-syntax
Correct answer: ansible-playbook site.yml --syntax-check
--syntax-check parses the playbook and reports YAML and Ansible syntax errors without connecting to or modifying any hosts.
Question 6: Which Ansible professional practice reduces playbook execution time on large inventories without changing logic?
- Removing all handlers
- Increasing 'forks' in ansible.cfg to allow more parallel host connections (Correct answer)
- Using serial: 1 to prevent race conditions
- Disabling fact gathering globally
Correct answer: Increasing 'forks' in ansible.cfg to allow more parallel host connections
The 'forks' setting controls how many hosts Ansible manages concurrently; increasing it reduces total execution time proportionally.
Question 7: What professional standard applies when a playbook must deploy to production and a mistake could cause downtime?
- Run the full playbook immediately to avoid delays
- Use '--check' mode and '--diff' to preview changes before applying them to production (Correct answer)
- Disable error handling to prevent playbook interruption
- Run only on a subset using serial: 100%
Correct answer: Use '--check' mode and '--diff' to preview changes before applying them to production
Check mode with diff previews what changes would be made without applying them, enabling safe review before production execution.
A professional Ansible developer is asked to share a role with the broader community.
Which platform and format is the industry standard?