给 playbook 的任务添加标签,在运行任务的时候指定标签
---
- name: ansible playbook
hosts: all
remote_user: root
become: yes
tasks:
- name: 测试连接
ping:
tags:
- test
ansible tags:
ansible-playbook play.yml --tags 'test'
ansible-playbook play.yml --skip-tags 'test'