LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

You add tags: web to an import_tasks and to an include_tasks. Which tasks get the tag in each case?

On an import, every imported task inherits the tag. On an include, only the include task gets it; the tasks in the file don't, unless you pass the tag with apply:.

Tags follow the same rule as when:. Keywords on an import are copied onto every imported task, so --tags web runs all of them.

On an include, the keyword stays on the include task. --tags web selects the include, which then loads the file, but the tasks inside have no web tag and are skipped. To pass keywords on to the tasks inside, use apply:

- name: Include web tasks with the tag applied
  ansible.builtin.include_tasks:
    file: webserver_tasks.yml
    apply:
      tags: web
  tags: web

The outer tags: web makes --tags web select the include; apply: tags: web gives the tag to every task inside.

Go deeper:

From Quiz: ITIA / Ansible: Complex Playbooks with Imports and Includes | Updated: Nov 26, 2026