一、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标签(四)

ansible-playbook之tags标签(四)

ansible-playbook之tags标签(四)

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2022-01-04
  • 2021-07-13
  • 2021-06-27
  • 2021-08-20
  • 2022-02-25
猜你喜欢
  • 2021-09-22
  • 2022-02-23
  • 2022-01-07
  • 2022-02-20
  • 2021-09-30
  • 2021-08-15
相关资源
相似解决方案