一、tags標簽
[root@linux-node1 ansible]# cat httpd.yaml --- - hosts: date remote_user: root tasks: - name: install httpd package yum: name=httpd tags: inshttpd - name: copy conf file copy: src=files/httpd.conf dest=/etc/httpd/conf backup=yes notify: restart service - name: start service service: name=httpd state=started enabled=yes tags: rshttpd handlers: - name: restart service service: name=httpd state=restarted
二、執行自己定義的標簽 (-t 加自定義標簽)、標簽名字可以一樣,如果調用會同時執行
ansible-playbook -t inshttpd,rshttpd httpd.yaml