nginx.yml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. - name: Ensure nginx configuration is up to date
  2. become: yes
  3. template:
  4. src: "{{ item.src }}"
  5. dest: "/etc/nginx/sites-available/{{ item.dest }}"
  6. with_items:
  7. - src: gogs_nginx.conf.j2
  8. dest: gogs.conf
  9. - src: gogs_unsecure.conf.j2
  10. dest: gogs_unsecure.conf
  11. - name: Ensure unsecure nginx configuration is up to date
  12. become: yes
  13. template:
  14. src: gogs_unsecure.conf.j2
  15. dest: /etc/nginx/sites-available/gogs_unsecure.conf
  16. - name: Ensure unsecure gogs configuration for nginx is enabled
  17. become: yes
  18. file:
  19. state: link
  20. dest: /etc/nginx/sites-enabled/gogs_unsecure.conf
  21. src: /etc/nginx/sites-available/gogs_unsecure.conf
  22. notify: Reload nginx
  23. - name: Ensure nginx is running
  24. become: yes
  25. service:
  26. name: nginx
  27. state: started
  28. - stat:
  29. path: "/var/lib/acme/live/{{ gogs_domain }}/privkey"
  30. become: yes
  31. register: gogs_key_file_stat
  32. - name: Let acmetool generate a key and a certificate
  33. become: yes
  34. when: not gogs_key_file_stat.stat.exists
  35. shell: /usr/bin/acmetool want --batch {{ gogs_domain }}
  36. notify: Restart nginx
  37. - name: Ensure gogs configuration for nginx is enabled
  38. become: yes
  39. file:
  40. state: link
  41. dest: /etc/nginx/sites-enabled/gogs.conf
  42. src: /etc/nginx/sites-available/gogs.conf
  43. notify: Reload nginx