• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Ansible by
Q:
Explain Ansible Tags

1 Answer

0 votes
by

If you have a large playbook, it becomes useful to be able to run only a specific part of it rather than running everything in the playbook. Ansible supports a tag attribute for this reason.

When you apply tags on things, then you can control whether they are executed by adding command-line options.

When you execute a playbook, you can filter tasks based on the tags in two ways, such as:

  1. tasks:  
  2. - yum:  
  3.     name: "{{ item }}"  
  4.     state: present  
  5.   loop:  
  6.   - httpd  
  7.   - memcached  
  8.   tags:  
  9.   - packages  
  10.   
  11. - template:  
  12.     src: templates/src.j2  
  13.     dest: /etc/foo.conf  
  14.   tags:  
  15.   - configuration  

Related questions

0 votes
asked Feb 12, 2020 in Ansible by miceperry
0 votes
asked Oct 7, 2020 in Ansible by Robindeniel
...