在ansible中,tags(标签)不是一个独立模块,而是playbook的一个关键字,用于给任务打标签,以便在执行时选择性运行或跳过某些任务。1.基本语法- hosts: all tasks: - name: Install httpd yum: name: httpd state: present tags: - install - name: Start httpd service: name: httpd state: started tags: - start2.执行指定标签的任务1.只执行install标签对应的任务ansible-playbook-2 httpd.yaml --tags install结果:-install httpd会执行-start httpd不会执行[root@cent79-2 yaml-directory]# ansible-playbook-2 httpd.yaml --tags install PLAY [all] ******************************************************************************* TASK [Gathering Facts] ******************************************************************* ok: [192.168.10.100] TASK [Install httpd] ********************************************************************* ok: [192.168.10.100] PLAY
