You should use tags: as described in http://docs.ansible.com/playbooks_tags.html
If you have a large playbook, it may be useful to run a specific part of the configuration without starting the entire tutorial.
Both games and tasks support the "tags:" attribute for this reason.
Example:
tasks: - yum: name={{ item }} state=installed with_items: - httpd - memcached tags: - packages - template: src=templates/src.j2 dest=/etc/foo.conf tags: - configuration
If you want to just run part of the โconfigurationโ and โpackagesโ from a very long piece, you can do this:
ansible-playbook example.yml --tags "configuration,packages"
On the other hand, if you want to run a playbook without specific tasks, you can do this:
ansible-playbook example.yml --skip-tags "notification"
You can also apply tags to roles:
roles: - { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }
And you can also flag basic include statements:
- include: foo.yml tags=web,foo
Both of them have the function of marking each individual task inside the include statement.
Mxx May 30 '14 at 4:29 2014-05-30 04:29
source share