From the course: Ansible Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Using tags

Using tags

- [Instructor] In the previous video, you learned how simple it can be to target specific systems for Ansible tasks, but what about being specific about what tasks you'd like to run against these systems. Well, we can use tags in our tasks within playbooks, and then reference these tags when we are running the playbook. As you might guess, tags are very easy to implement and use in Ansible. Notice, we're just going to be using a simple tags reference inside the playbook. Let's see this in action. So let's take a look at a playbook that I have called tags.yml. And inside this playbook, you can see that we have three tasks, and these tasks are to install Apache2, to install NTP and to start NTP. Notice what I've done, I've included the tags for each of these tasks. We have the Apache2 tag, the NTP tag and the NTP_start tag. Notice, also, that we could've taken the tags reference and done it higher up in the hierarchy.…

Contents