ansible-playbook之tags标签(四)

一、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

原文地址:https://www.cnblogs.com/zhaojingyu/p/12115738.html