
上QQ阅读APP看书,第一时间看更新
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
- routing
- name: Print NTP
debug:
msg: "Router {{ hostname }} will run NTP"
tags: ntp
- Run the playbook as shown here:
$ ansible-playbook ansible_tags.yml -i hosts --tags routing
- Run the playbook again, this time using tags, as shown here:
$ ansible-playbook ansible_tags.yml -i hosts --tags ospf
$ ansible-playbook ansible_tags.yml -i hosts --tags routing