9

In Ansible, is it possible to define a set of tasks in one files and then run selected tasks from other playbooks? The documentation describes how to include and reuse the task list, is there a way to run only selected tasks and not the full list?

kefeizhou
  • 211
  • 3
  • 7

1 Answers1

11

You can do so by either using roles: http://www.ansibleworks.com/docs/playbooks_roles.html

or by tagging individual tasks you want to be able to turn off: http://www.ansibleworks.com/docs/playbooks_tags.html

You can even combine the two, as described on the tags page:

You may also apply tags to roles:

roles:
  - { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }
senorsmile
  • 713
  • 8
  • 20
  • 5
    There is no way for a playbook to invoke specific tags in another role or playbook. The only way to filter by tags is on the command line. – augurar Aug 25 '15 at 17:39