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

Note:
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

Popular posts from this blog

Top 10 Git Commands

Kubernetes cluster setup NOTES step by step using minikube

SonarQube Installation & Configuration Step by step