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
In an Ansible playbook, what is the purpose of the 'become: true' directive?
Answer: It enables privilege escalation so tasks run as a different user (e.g., root)
'become: true' enables privilege escalation, typically via sudo, allowing tasks to run as root or another privileged user.
What is the difference between 'import_playbook' and 'include_playbook' in Ansible?
Answer: import_playbook is static (processed at parse time) while include_playbook is dynamic (processed at runtime)
Static imports are processed when the playbook is parsed, enabling features like --list-tasks. Dynamic includes are processed during execution, enabling conditional logic.
How do you reference a variable named 'app_port' inside a task's module arguments in an Ansible playbook?
Answer: {{ app_port }}
Ansible uses Jinja2 templating syntax with double curly braces to reference variables within task arguments.
What keyword in a playbook task definition allows you to run a task only when a specific condition is true?
Answer: when
The 'when' keyword evaluates a Jinja2 expression and only runs the task if it evaluates to true.
What is the purpose of 'vars_prompt' in an Ansible playbook?
Answer: It prompts the user for variable values interactively at playbook runtime
'vars_prompt' enables interactive playbook runs by asking the user to enter values for specified variables before task execution begins.
In Ansible, what is a 'magic variable' and which one contains the hostname of the current managed host?
Answer: Magic variables are special built-in variables set by Ansible; 'inventory_hostname' contains the current host's name
'inventory_hostname' is a magic variable that holds the name of the current host as defined in the inventory.
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