Ansible Tags is a powerful tool that allows us to tag specific tasks within a large Ansible playbook and provides us with the flexibility to choose which tasks will run within a given playbook based on the tags we specify. In this recipe, we will outline how to configure and use Ansible Tags.
Using Ansible Tags
How to do it...
- Create a new Ansible playbook called ansible_tags.yml, as shown here:
---
- name: Using Ansible Tags
hosts: cisco
gather_facts: no
tasks:
- name: Print OSPF
debug:
msg: "Router {{ hostname }} will Run OSPF"
tags: [ospf, routing]
- name: Print BGP
debug:
msg: "Router {{ hostname }} will Run BGP"
tags:
- bgp
...