在常见的web服务中,当配置文件发生修改时,需要进行重启服务。
剧本

---
- hosts: websrvs
  remote_user: root

  tasks:
    - name: Install Httpd Package
      yum: name=httpd
    - name: Httpd config file Copy
      copy: src=files/httpd.conf dest=/etc/httpd/conf/ backup=yes
      notify: Restart Httpd
      #当配置文件发生改变就通知Restrt Httpd
    - name: Service Start
      service: name=httpd satte=started enabled=yes

  handlers:
    - name: Restart Httpd
      service: name=httpd state=restarted 
      #收到通知时做出的动作
Last modification:October 19th, 2019 at 09:23 pm
If you think my article is useful to you, please feel free to appreciate