ansible.builtin.import_tasks (v2.11.12) — module

Import a task list

| "added in version" 2.4 of ansible.builtin"

Authors: Ansible Core Team (@ansible)

Install Ansible via pip

Install with pip install ansible-core==2.11.12

Description

Imports a list of tasks to be added to the current playbook for subsequent execution.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- hosts: all
  tasks:
    - debug:
        msg: task1

    - name: Include task list in play
      import_tasks: stuff.yaml

    - debug:
        msg: task10
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- hosts: all
  tasks:
    - debug:
        msg: task1

    - name: Apply conditional to all imported tasks
      import_tasks: stuff.yaml
      when: hostvar is defined

Inputs

    
free-form:
    description:
    - The name of the imported file is specified directly without any other option.
    - Most keywords, including loops and conditionals, only applied to the imported tasks,
      not to this statement itself.
    - If you need any of those to apply, use M(ansible.builtin.include_tasks) instead.

See also