You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.4 KiB

  1. ---
  2. - name: Add APT key for nginx repository
  3. apt_key:
  4. url: https://nginx.org/keys/nginx_signing.key
  5. - name: Add nginx APT repository
  6. apt_repository:
  7. repo: deb http://nginx.org/packages/debian bookworm nginx
  8. - name: Install nginx
  9. apt:
  10. name: nginx
  11. - name: Remove nginx from init.d (may conflict with systemd service)
  12. file:
  13. path: /etc/init.d/nginx
  14. state: absent
  15. when: is_docker
  16. - name: Update rc.d to reflect init.d removal
  17. command:
  18. cmd: update-rc.d nginx remove
  19. when: is_docker
  20. - name: Create nginx user
  21. user:
  22. name: nginx
  23. create_home: false
  24. - name: Create nginx.conf file
  25. template:
  26. src: nginx.conf.jinja2
  27. dest: /etc/nginx/nginx.conf
  28. owner: root
  29. group: root
  30. mode: 0644
  31. notify:
  32. - Reload nginx
  33. - name: Create sites-available directory
  34. file:
  35. path: /etc/nginx/sites-available
  36. state: directory
  37. owner: root
  38. group: root
  39. mode: 0755
  40. - name: Create sites-enabled directory
  41. file:
  42. path: /etc/nginx/sites-enabled
  43. state: directory
  44. owner: root
  45. group: root
  46. mode: 0744
  47. - name: Disable nginx default site
  48. file:
  49. path: /etc/nginx/sites-enabled/default
  50. state: absent
  51. notify:
  52. - Reload nginx
  53. - name: Start and enable nginx service
  54. systemd_service:
  55. name: nginx
  56. state: started
  57. enabled: true
  58. - name: Add logrotate config
  59. copy:
  60. src: logrotate
  61. dest: /etc/logrotate.d/nginx
  62. owner: root
  63. group: root
  64. mode: 0644