Ansible Playbook Structure and Variables Flashcards
6 cards from real Ansible Automation practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Ansible Playbook Structure and Variables flashcards as text
Which YAML key is used at the top level of an Ansible playbook to define which hosts the play targets?
Answer: hosts
The 'hosts' key at the top level of a play specifies which hosts or groups from inventory the play will run against.
What is the correct way to define a variable inline within a playbook using the 'vars' block?
Answer: vars:\n my_var: value
The 'vars' block is the standard way to define play-level variables directly within a playbook.
In Ansible variable precedence, which variable type has the highest priority and overrides all others?
Answer: Extra vars passed with -e on the command line
Extra variables passed via '-e' or '--extra-vars' on the command line have the highest precedence in Ansible's variable hierarchy.
What Ansible module is commonly used to include a variable file into a playbook at runtime?
Answer: include_vars
'include_vars' dynamically loads variables from a file during task execution, allowing conditional variable loading.
What does the 'gather_facts: false' setting in a playbook do?
Answer: Skips the automatic collection of system information from managed hosts
Setting 'gather_facts: false' disables the implicit 'setup' module call that collects host facts, speeding up playbooks that don't need system information.
Which Jinja2 filter would you use to set a default value for a variable that might be undefined in an Ansible template?
Answer: {{ my_var | default('fallback') }}
The 'default' Jinja2 filter provides a fallback value when the variable is undefined or empty.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy
Sources & references
Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy
- redhat.com — Score release, test delivery, renewal, score validity, exam information · verified Oct 2026
- docs.redhat.com — Fees, exam format, retake policy · verified Oct 2026