main.yml 955 B

123456789101112131415161718192021222324252627282930
  1. ---
  2. - name: restart nginx
  3. debug: msg="checking config first"
  4. changed_when: True
  5. notify:
  6. - check nginx configuration
  7. - restart nginx - after config check
  8. - name: reload nginx
  9. debug: msg="checking config first"
  10. changed_when: True
  11. notify:
  12. - check nginx configuration
  13. - reload nginx - after config check
  14. - name: check nginx configuration
  15. shell: "{{ nginx_binary_name }} -t"
  16. register: result
  17. changed_when: "result.rc != 0"
  18. always_run: yes
  19. when: nginx_installation_type in nginx_installation_types_using_service
  20. - name: restart nginx - after config check
  21. service: name={{ nginx_service_name }} state=restarted
  22. when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on"
  23. - name: reload nginx - after config check
  24. service: name={{ nginx_service_name }} state=reloaded
  25. when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on"