nginx.yml 843 B

123456789101112131415161718192021222324252627282930313233
  1. ---
  2. - name: Ensure nginx configuration is up to date
  3. become: yes
  4. template:
  5. src: "prometheus_nginx.conf.j2"
  6. dest: "/etc/nginx/sites-available/prometheus.conf"
  7. notify: Reload nginx
  8. - name: Ensure nginx is running
  9. become: yes
  10. service:
  11. name: nginx
  12. state: started
  13. - stat:
  14. path: "/var/lib/acme/live/{{ prometheus_domain }}/privkey"
  15. become: yes
  16. register: prometheus_key_file_stat
  17. - name: Let acmetool generate a key and a certificate
  18. become: yes
  19. when: not prometheus_key_file_stat.stat.exists
  20. shell: /usr/bin/acmetool want --batch {{ prometheus_domain }}
  21. notify: Restart nginx
  22. - name: Ensure prometheus configuration for nginx is enabled
  23. become: yes
  24. file:
  25. state: link
  26. dest: /etc/nginx/sites-enabled/prometheus.conf
  27. src: /etc/nginx/sites-available/prometheus.conf
  28. notify: Reload nginx