http_nginx.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ---
  2. - name: "[NGINX] - remove some commented line in php-fpm conf"
  3. ansible.builtin.lineinfile:
  4. dest: "{{ php_dir }}/fpm/pool.d/www.conf"
  5. regexp: '^\;env'
  6. state: absent
  7. # validate: "/usr/sbin/{{ php_bin }} -t #%s"
  8. notify: reload php-fpm
  9. - name: "[NGINX] - Add path variable to php-fpm"
  10. ansible.builtin.blockinfile:
  11. dest: "{{ php_dir }}/fpm/pool.d/www.conf"
  12. insertafter: '^; Default Value: clean env$'
  13. marker: "; {mark} ANSIBLE MANAGED BLOCK"
  14. block: |
  15. env[HOSTNAME] = $HOSTNAME
  16. env[PATH] = $PATH
  17. env[TMP] = /tmp
  18. env[TMPDIR] = /tmp
  19. env[TEMP] = /tmp
  20. notify: reload php-fpm
  21. - name: "[NGINX] - enable APC for php CLI"
  22. ansible.builtin.lineinfile:
  23. dest: "{{ php_dir }}/cli/php.ini"
  24. line: "apc.enable_cli = 1"
  25. insertbefore: "^; End:$"
  26. state: present
  27. # validate: "/usr/sbin/{{ php_bin }} -t #%s"
  28. notify: reload php-fpm
  29. - name: "[NGINX] - enable PHP OPcache for php.ini"
  30. ansible.builtin.lineinfile:
  31. dest: "{{ php_dir }}/fpm/php.ini"
  32. state: present
  33. regexp: "{{ item.regexp }}"
  34. line: "{{ item.line }}"
  35. backrefs: true
  36. with_items:
  37. - { regexp: 'opcache.enable=0', line: 'opcache.enable=1' }
  38. - { regexp: 'opcache.enable_cli', line: 'opcache.enable_cli=1' }
  39. - { regexp: 'opcache.interned_strings_buffer', line: 'opcache.interned_strings_buffer=8' }
  40. - { regexp: 'opcache.max_accelerated_files', line: 'opcache.max_accelerated_files=10000' }
  41. - { regexp: 'opcache.memory_consumption', line: 'opcache.memory_consumption=128' }
  42. - { regexp: 'opcache.save_comments', line: 'opcache.save_comments=1' }
  43. - { regexp: 'opcache.revalidate_freq', line: 'opcache.revalidate_freq=1' }
  44. - { regexp: 'memory_limit', line: 'memory_limit={{ php_memory_limit }}'}
  45. # validate: "/usr/sbin/{{ php_bin }} -t #%s"
  46. notify: reload php-fpm
  47. - name: "[NGINX] - Public Diffie-Hellman Parameter are generated. This might take a while."
  48. ansible.builtin.command: "openssl dhparam -out {{ nextcloud_tls_dhparam }} 2048"
  49. args:
  50. creates: "{{ nextcloud_tls_dhparam }}"
  51. - name: "[NGINX] - php handler configuration is present."
  52. ansible.builtin.template:
  53. dest: /etc/nginx/sites-available/php_handler.cnf
  54. src: templates/nginx_php_handler.j2
  55. mode: 0640
  56. notify: reload http
  57. - name: "[NGINX] - php handler is enabled"
  58. ansible.builtin.file:
  59. path: /etc/nginx/sites-enabled/php_handler
  60. src: /etc/nginx/sites-available/php_handler.cnf
  61. state: link
  62. notify: reload http
  63. - name: "[NGINX] - generate Nextcloud configuration for nginx"
  64. ansible.builtin.template:
  65. dest: /etc/nginx/sites-available/nc_{{ nextcloud_instance_name }}.cnf
  66. src: "{{ nextcloud_websrv_template }}"
  67. mode: 0640
  68. notify: reload http
  69. - name: "[NGINX] - Enable Nextcloud in nginx conf"
  70. ansible.builtin.file:
  71. path: /etc/nginx/sites-enabled/nc_{{ nextcloud_instance_name }}
  72. src: /etc/nginx/sites-available/nc_{{ nextcloud_instance_name }}.cnf
  73. state: link
  74. notify: reload http
  75. - name: "[NGINX] - Disable nginx default site"
  76. ansible.builtin.file:
  77. path: /etc/nginx/sites-enabled/default
  78. state: absent
  79. when: nextcloud_disable_websrv_default_site | bool
  80. notify: reload http