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

ansible-playbook之tags标签(四)_第1张图片

ansible-playbook之tags标签(四)_第2张图片

ansible-playbook之tags标签(四)_第3张图片

你可能感兴趣的:(ansible-playbook之tags标签(四))