Pushed some code to support "tags" on resources, which are an optional thing you can use only if you want them.
Long email as I attempt to explain the concept and my thinking behind it…which is not new in configuration management tools, but how it applies to ansible is new, and
not everyone may have seen it somewhere else.
=== Part One ===
The idea behind tags is to be able to run only specific parts of a playbook.
For instance, assume we describe our entire infrastructure in a playbook, mapping each "like" group of systems to particular roles, as represented by include files,
and have one playbook called site.yml:
- hosts: webservers
tasks:
- include: tasks/common.yml
- include: tasks/apache.yml
- hosts: dbservers
tasks:
- include: tasks/common.yml
- include: tasks/apache.yml
What happens if I just want to change the NTP server address on all my servers, very quickly? Well, I don't need to run everything, I just want to run
a particular step in tasks/common.yml -- but not all of them.
So I write that individual task like this:
- name: update ntp server config
action: template src=templates/ntp.yml dest=/etc/ntp.conf
tags: ntp
(Note that I could have applied multiple tags by using a YAML list of strings for "tags", but it also takes a string to avoid surprises)
If I run the playbook normally, it does everything to all of my machines:
ansible-playbook site.yml
Though I can also choose to just run the NTP steps
ansible-playbook site.yml --tags ntp
If I want more than one tag, I can do that too:
ansible-playbook site.yml -- tags "ntp,acme"