一个playbook
文件中,执行时如果想执行某一个任务,那么可以给每个任务集进行打标签,这样在执行的时候可以通过-t
选择指定标签执行,
还可以通过--skip-tags
选择除了某个标签外全部执行等
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
[root@ansible PlayBook]# cat httpd.yml --- - hosts: 192.168.1.31 remote_user: root tasks: - name: install httpd yum: name=httpd state=installed tags: inhttpd - name: start httpd service: name=httpd state=started tags: sthttpd - name: restart httpd service: name=httpd state=restarted tags: - rshttpd - rs_httpd
通过-t
选项指定tags
进行执行
[root@ansible PlayBook]# ansible-playbook -t rshttpd httpd.yml
通过--skip-tags
选项排除不执行的tags
[root@ansible PlayBook]# ansible-playbook --skip-tags inhttpd httpd.yml
本文来自博客园,作者:topass123,转载请注明原文链接:https://www.cnblogs.com/topass123/p/12555921.html