← Back to Quiz Home
Test your knowledge on roles, variables, and flow control.
Which variable definition has the highest precedence?
Variables passed via the command line (-e) always override all other variable definitions.
Which directory in a role is intended for default variables that are easily overridden?
defaults/main.yml is for setting baseline values that users can change without modifying the role itself.
What is the effect of serial: 1 in a playbook?
serial controls the rolling update batch size, processing the play on a batch of hosts before moving to the next.
How do you iterate over a list in a task?
loop is the modern standard keyword for iteration, replacing with_items.
Which keyword allows you to execute a task only if a specific condition is met?
when provides the conditional logic (e.g., when: ansible_os_family == "RedHat").
What triggers a Handler to run?
Handlers are event-driven and strictly require a notification from a changed task.
What tool is used to encrypt sensitive data in Ansible?
Ansible Vault allows you to keep passwords and keys in encrypted files.
Which Jinja2 filter would you use to get the last element of a path?
{{ "/etc/httpd/conf/httpd.conf" | basename }} returns httpd.conf.
How do you execute a task on the localhost regardless of the target host in the play?
delegate_to allows you to change the execution context of a specific task.
Which Ansible feature allows you to group tasks and handle errors (try/catch)?
Blocks allow logical grouping and error handling logic similar to programming languages.
What is the purpose of the templates directory in a role?
Templates are dynamic files processed by the Jinja2 engine before being copied to the destination.
Which keyword runs a task asynchronously, allowing Ansible to proceed without waiting?
async specifies the maximum runtime, and poll specifies how often to check for completion.
What command creates the directory structure for a new role?
ansible-galaxy init role_name creates the standard directory skeleton.
Which module is used to ensure a service is started and enabled?
service is the generic wrapper; systemd is the specific module for systemd-based systems.
How do you access variables from another host?
hostvars is a magic variable containing the variables and facts of all other hosts in the inventory.
What is the default fork count (parallel processes) in Ansible?
By default, Ansible communicates with 5 hosts in parallel. This can be increased in ansible.cfg.
Which lookup plugin reads the contents of a file on the controller?
{{ lookup('file', '/path/to/file') }} reads the file content into a variable.
What is the difference between import_playbook and include_playbook?
Static imports are processed before execution begins; dynamic includes are processed when reached.
Which variable contains the hostname of the machine Ansible is currently running on (controller)?
inventory_hostname is the name of the host as defined in the inventory. ansible_hostname is the discovered hostname fact.
How do you suppress the output of a task that prints potential secrets?
no_log: true prevents the task details (inputs and outputs) from being printed to the logs or console.
Quiz Progress
0 / 0 questions answered
(0%)
0 correct
Quiz Complete!
0%