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.

123 lines
3.8 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/site.yml
  12. - ./../../vars/php.yml
  13. - ./../../vars/nginx.yml
  14. vars:
  15. nginx_acme: False
  16. nginx_http_extra_options: |
  17. client_max_body_size 100M;
  18. nginx_real_ip_from: ['172.16.30.0/24']
  19. nginx_default_keepalive_timeout: 65
  20. # nginx_webroot_create: False
  21. nginx_ocsp: False
  22. nginx_worker_processes: auto
  23. nginx_manage_ipv6only: False
  24. # TODO: Replace [::]:443 to 443 and [::]:80 to 80 in site nginx config
  25. nginx__servers:
  26. - name: '{{ domain_name }}'
  27. type: php
  28. root: '/var/www/{{ site_name }}'
  29. public_dir_name: ''
  30. include_files_begin: '{{ nginx_includes_begin }}'
  31. options: 'set $upstream unix:/run/{{ php__version_preference[0] }}-fpm-www-data.sock;'
  32. location_list:
  33. - pattern: '/'
  34. locations:
  35. - pattern: '~ ^/.*-backend/'
  36. options: |
  37. try_files /index.html @october
  38. set $upstream unix:/run/{{ php__version_preference[0] }}-fpm-backend.sock
  39. options: try_files /index.html @october;
  40. - pattern: '@october'
  41. options: rewrite ^/.*$ /index.php last;
  42. - pattern: '~* ^(?!/index).*\.php$'
  43. options: return 403;
  44. php_options: |
  45. fastcgi_read_timeout 3000;
  46. php_upstream: $upstream
  47. #location ~ ^(?!.+\.php/)(?<script_name>.+\.php)$ {
  48. php_location_script_name: ~ ^(?<script_name>/index\.php)
  49. #location ~ ^(?<script_name>.+?\.php)(?<path_info>/.*)?$ {
  50. php_location_path_info: ~ ^(?<script_name>/index\.php)(?<path_info>/.*)?
  51. pre_tasks:
  52. - name: Set filtered includes
  53. set_fact:
  54. nginx_includes_begin: "{{ (nginx_includes_begin | default([])) | union([item]) }}"
  55. when: item != omit
  56. loop:
  57. - "{{ (nginx_www_domain and nginx_www_redirect == 'www') | ternary('includes.d/www.conf', omit) }}"
  58. - "{{ (nginx_www_domain and nginx_www_redirect == 'non-www') | ternary('includes.d/non-www.conf', omit) }}"
  59. - includes.d/octobercms.conf
  60. - includes.d/staticfiles.conf
  61. - name: Copy OctoberCMS nginx conf includes and www redirect
  62. copy:
  63. src: etc/nginx/includes.d
  64. dest: /etc/nginx/
  65. mode: 0644
  66. - name: Copy map config for www/non-www redirects
  67. copy:
  68. src: etc/nginx/conf.d/map_tld_domain.conf
  69. dest: /etc/nginx/conf.d/
  70. mode: 0644
  71. post_tasks:
  72. - name: Default index.html
  73. template:
  74. src: var/www/site_name/index.html.j2
  75. dest: '/var/www/{{ site_name }}/index.html'
  76. mode: 0644
  77. owner: '{{ site_name }}'
  78. - name: Copy normalized.css
  79. template:
  80. src: var/www/site_name/normalize.css
  81. dest: '/var/www/{{ site_name }}/'
  82. mode: 0644
  83. owner: '{{ site_name }}'
  84. roles:
  85. # - role: keyring
  86. # tags: [ 'role::keyring', 'skip::keyring', 'role::nginx' ]
  87. # keyring__dependent_apt_keys:
  88. # - '{{ nginx__keyring__dependent_apt_keys }}'
  89. #
  90. # - role: apt_preferences
  91. # tags: [ 'role::apt_preferences', 'skip::apt_preferences' ]
  92. # apt_preferences__dependent_list:
  93. # - '{{ nginx__apt_preferences__dependent_list }}'
  94. #
  95. # - role: python
  96. # tags: [ 'role::python', 'skip::python' ]
  97. # python__dependent_packages3:
  98. # - '{{ nginx__python__dependent_packages3 }}'
  99. # python__dependent_packages2:
  100. # - '{{ nginx__python__dependent_packages2 }}'
  101. - role: nginx
  102. tags: [ 'role::nginx', 'skip::nginx' ]