Interview Prep/Ansible/Roles, Collections and Project Structure

How do you apply only part of a role, for instance only its configuration?

BeginnerScenarioRoles, Collections and Project Structure
Answer

Situation read → Selective execution.

What I'd do → Tag tasks and use --tags.

- ansible.builtin.template: { src: app.conf.j2, dest: /etc/app.conf }
  tags: [config]
ansible-playbook site.yml --tags config

Why → Tags let you apply a slice without editing code.

Interview tip → Tags on import_tasks apply to every task inside; on include_tasks only to the include.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Project Structure