Ansible organizes automation content through collections and roles. Master the vocabulary for collections, roles, handlers, facts, Jinja2 templates, and idempotency — the foundations of reliable, repeatable infrastructure automation.
0 / 5 completed
1 / 5
A team organizes reusable Ansible content into a collection. What can an Ansible collection contain?
An Ansible collection is a distribution format that bundles modules, roles, plugins (action, filter, lookup, etc.), playbooks, and documentation into a namespaced package (e.g., community.general). Collections are installable via ansible-galaxy collection install and versioned independently of Ansible core.
2 / 5
An Ansible role has a handlers/ directory. When does a handler run?
Ansible handlers are special tasks triggered by notify directives. They run only once, at the end of the play (or at an explicit meta: flush_handlers point), and only if at least one task that notified them reported a change. This pattern is used for actions like restarting a service only when its config file changed.
3 / 5
An Ansible task uses ansible_facts['os_family']. What are Ansible facts?
Ansible facts are system information automatically gathered from managed hosts when a play runs (via the setup module, enabled by gather_facts: true). They include OS family, distribution, IP addresses, memory, mounted filesystems, and more — accessible as ansible_facts variables throughout the play.
4 / 5
A Jinja2 template in an Ansible role uses {{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}. What does hostvars provide?
hostvars is a special Ansible variable that gives access to facts and variables of any host in the inventory, not just the current one. This enables cross-host templating — for example, referencing another server's IP address when configuring a load balancer or database client.
5 / 5
An Ansible task is described as idempotent. What does idempotency mean for Ansible modules?
Idempotency means a task produces the same system state whether run once or many times. A well-written Ansible module checks the current state first and only makes changes if needed. This property is fundamental to Ansible's design — playbooks can be safely re-run after partial failures or to enforce desired state without side effects.