ansible-playbook tags 使用

yaml文件内容

---
- hosts: websrvs
  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:  httpd state=started  enabled=yes  
      tags: rshttpd

  handlers:
    - name: restart servlce
      service: name=httpd state=restarted
# 执行命令
ansible-playbook -t inshttpd,rshttpd httpd.yml

这样就会只执行 inshttpd 和 rshttpd 两个tags的任务

可以多个动作公用一个标签;

posted @ 2021-09-06 15:09  Star-Hitian  阅读(61)  评论(0)    收藏  举报