FreeKB - ansible-playbook command - include_tasks
ansible-playbook command - include_tasks

Home > Search


This assumes you have installed Ansible Tower and are familiar with the ansible-playbook command. Let's say you've multple playbooks with identical tasks, like this.

- name: standard task
  shell: "some command"
  register: foo

 

Instead of having this markup in multiple playbooks, you could create a unique playbook, such as foo.yml, that contains the task. Then, when you need to perform "standard task", you can use the include_tasks statement to include foo.yml, like this.

- include_tasks: foo.yml

 

include_tasks must be used within tasks, like this.

- hosts: all
  tasks:
    - include_tasks: foo.yml

 

import_playbook cannot be run inside a task meaning that you would use import_playbook to run a play outside of tasks.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 2b140 in the box below so that we can be sure you are a human.




Comments