Chapter 8: Simplifying Playbooks with Roles and Collections
Ansible roles and collections quiz
Fifteen questions on roles and collections. Aim for at least nine before moving on to chapter 9.
- Which command creates the standard directory structure for a new role named `backup` under `roles/`?
- In which directory of a role do handlers go?
- A play lists `tasks`, then `roles`. Which runs first?
- A handler is notified by a task in `pre_tasks`. When does it run?
- A role’s `defaults/main.yml` sets `app_port: 8080`, and `group_vars/web.yml` sets `app_port: 9090`. Which does a web host use?
- The same role also has `app_port: 8080` in `vars/main.yml`. Now which value does the web host use?
- What does listing a role under `dependencies` in `meta/main.yml` do?
- How do you apply the SELinux system role from its collection?
- What does this command do?
- In a requirements file, what are `src` and `name`?
- A project’s `ansible.cfg` has `collections_path = ./collections`. A play that uses `ansible.posix.firewalld`, installed in `/usr/share/ansible/collections`, now fails. Why?
- You install a role from a requirements file without `-p roles`, and `roles_path` is not set. Where is it normally installed?
- Which setting overrides even the values in a role’s `vars/main.yml`?
- The selinux system role reports that a reboot is required. How do you complete the change in the same run?
- A task fails on the managed host with "Cannot detect the required Python library". What is missing?