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.

111 lines
3.3 KiB

  1. ---
  2. - name: Manage nginx webserver
  3. collections: [ 'debops.debops', 'debops.roles01',
  4. 'debops.roles02', 'debops.roles03' ]
  5. hosts: [ 'debian10' ]
  6. become: True
  7. environment: '{{ inventory__environment | d({})
  8. | combine(inventory__group_environment | d({}))
  9. | combine(inventory__host_environment | d({})) }}'
  10. vars_files:
  11. - ./../vars/nginx.yml
  12. vars:
  13. nginx_acme: False
  14. nginx_http_extra_options: |
  15. client_max_body_size 100M;
  16. nginx_real_ip_from: ['172.16.30.0/24']
  17. nginx_default_keepalive_timeout: 65
  18. # nginx_webroot_create: False
  19. nginx_ocsp: False
  20. nginx_worker_processes: auto
  21. nginx__servers:
  22. - name: '{{ site_name }}'
  23. type: php
  24. root: '/var/www/{{ site_name }}'
  25. public_dir_name: ''
  26. include_files_begin: '{{ nginx_includes_begin }}'
  27. options: set $upstream unix:/run/php7.4-fpm-www-data.sock;
  28. location_list:
  29. - pattern: '/'
  30. locations:
  31. - pattern: '~ ^/*.-backend/'
  32. options: set $upstream unix:/run/php7.4-fpm-backend.sock;
  33. options: try_files /index.html @october;
  34. - pattern: '@october'
  35. options: rewrite ^/.*$ /index.php last;
  36. - pattern: '~* ^(?!/index).*\.php$'
  37. options: return 403;
  38. php_options: |
  39. fastcgi_read_timeout 3000;
  40. php_upstream: $upstream
  41. #location ~ ^(?!.+\.php/)(?<script_name>.+\.php)$ {
  42. php_location_script_name: ~ ^(?<script_name>/index\.php)
  43. #location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
  44. php_location_path_info: ~ ^(?<script_name>/index\.php)(?<path_info>/.*)?
  45. pre_tasks:
  46. - name: Set filtered includes
  47. set_fact:
  48. nginx_includes_begin: "{{ (nginx_includes_begin | default([])) | union([item]) }}"
  49. when: item != omit
  50. loop:
  51. - "{{ (nginx_www_redirect | default(False)) | ternary('includes.d/www.conf', omit) }}"
  52. - includes.d/octobercms.conf
  53. - includes.d/staticfiles.conf
  54. - name: Copy OctoberCMS nginx conf includes and www redirect
  55. copy:
  56. src: etc/nginx/includes.d
  57. dest: /etc/nginx/
  58. mode: 0644
  59. post_tasks:
  60. - name: Default index.html
  61. template:
  62. src: var/www/site_name/index.html.j2
  63. dest: '/var/www/{{ site_name }}/index.html'
  64. mode: 0644
  65. owner: '{{ site_name }}'
  66. - name: Copy normalized.css
  67. template:
  68. src: var/www/site_name/normalize.css
  69. dest: '/var/www/{{ site_name }}/'
  70. mode: 0644
  71. owner: '{{ site_name }}'
  72. roles:
  73. # - role: keyring
  74. # tags: [ 'role::keyring', 'skip::keyring', 'role::nginx' ]
  75. # keyring__dependent_apt_keys:
  76. # - '{{ nginx__keyring__dependent_apt_keys }}'
  77. #
  78. # - role: apt_preferences
  79. # tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
  80. # apt_preferences__dependent_list:
  81. # - '{{ nginx__apt_preferences__dependent_list }}'
  82. #
  83. # - role: python
  84. # tags: [ 'role::python', 'skip::python' ]
  85. # python__dependent_packages3:
  86. # - '{{ nginx__python__dependent_packages3 }}'
  87. # python__dependent_packages2:
  88. # - '{{ nginx__python__dependent_packages2 }}'
  89. - role: nginx
  90. tags: [ 'role::nginx', 'skip::nginx' ]