Difference between revisions of "Ansible Tags"

From rbachwiki
Jump to navigation Jump to search
Line 9: Line 9:
       state: present
       state: present
     tags: i-apache
     tags: i-apache
-name: start apache
  service:
    name: apache2
    state: started
  tags: start_apache2
* The tag name could be anything
ansible-playbook nameofymlfile.yml -t tagname
* the <code> -t </code> flag must precede the tagname in the yml file

Revision as of 21:11, 13 July 2022

Ansible Tags

Tags are the reference or alias to a task

---
- name: setup apache ser er
  hosts: localhost
  tasks:
    apt:
      name: apache2
      state: present
   tags: i-apache
-name: start apache
 service:
   name: apache2
   state: started
 tags: start_apache2
  • The tag name could be anything
ansible-playbook nameofymlfile.yml -t tagname
  • the -t flag must precede the tagname in the yml file