Write Ansible Playbook using tags - (execute a specific task by using tag)
playbook name: task1.yaml
---
- name: install packages
hosts: all
become: yes
tasks:
- name: install httpd
yum:
name: httpd
state: present
tags: httpd
- name: install docker
yum:
name: docker
state: present
tags: docker
---
- name: install packages
hosts: all
become: yes
tasks:
- name: install httpd
yum:
name: httpd
state: present
tags: httpd
- name: install docker
yum:
name: docker
state: present
tags: docker
Note:
we have two tasks
1) Install httpd
2) Install docker
we have two tasks
1) Install httpd
2) Install docker
but I would like to execute only docker task by using tag name
step1: create playbook:
ex: playbook name: task1.yaml
step2: execution process:
ansible-playbook task1.yaml --tags docker
step3: result:
only docker software will be installed on target machines
vist our YouTube Channel: https://www.youtube.com/@VansroTechnologies/videos
Comments
Post a Comment