/docsite/rst/playbooks_tags.rst

https://github.com/ajanthanm/ansible · ReStructuredText · 56 lines · 35 code · 21 blank · 0 comment · 0 complexity · 1c3cb1f83e4ee3d03cb21abc53a62104 MD5 · raw file

  1. Tags
  2. ====
  3. If you have a large playbook it may become useful to be able to run a
  4. specific part of the configuration without running the whole playbook.
  5. Both plays and tasks support a "tags:" attribute for this reason.
  6. Example::
  7. tasks:
  8. - yum: name={{ item }} state=installed
  9. with_items:
  10. - httpd
  11. - memcached
  12. tags:
  13. - packages
  14. - template: src=templates/src.j2 dest=/etc/foo.conf
  15. tags:
  16. - configuration
  17. If you wanted to just run the "configuration" and "packages" part of a very long playbook, you could do this::
  18. ansible-playbook example.yml --tags "configuration,packages"
  19. On the other hand, if you want to run a playbook *without* certain tasks, you could do this::
  20. ansible-playbook example.yml --skip-tags "notification"
  21. You may also apply tags to roles::
  22. roles:
  23. - { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }
  24. And you may also tag basic include statements::
  25. - include: foo.yml tags=web,foo
  26. Both of these have the function of tagging every single task inside the include statement.
  27. .. seealso::
  28. :doc:`playbooks`
  29. An introduction to playbooks
  30. :doc:`playbooks_roles`
  31. Playbook organization by roles
  32. `User Mailing List <http://groups.google.com/group/ansible-devel>`_
  33. Have a question? Stop by the google group!
  34. `irc.freenode.net <http://irc.freenode.net>`_
  35. #ansible IRC chat channel