nginx.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. - name: 'Install nginx package'
  2. apt:
  3. pkg: 'nginx'
  4. state: 'installed'
  5. update_cache: 'yes'
  6. when: with_nginx
  7. - name: 'Install nginx default file configuration'
  8. template:
  9. src: 'nginx/default.j2'
  10. dest: '/etc/default/nginx'
  11. owner: 'root'
  12. group: 'root'
  13. mode: '0644'
  14. notify:
  15. - 'Restart nginx'
  16. when: with_nginx
  17. - name: 'Install nginx configuration'
  18. template:
  19. src: 'nginx/nginx.conf.j2'
  20. dest: '/etc/nginx/nginx.conf'
  21. owner: 'root'
  22. group: 'root'
  23. mode: '0644'
  24. notify:
  25. - 'Restart nginx'
  26. when: with_nginx
  27. - name: 'Install additional nginx configuration params (conf.d/)'
  28. template:
  29. src: 'nginx/conf.d/{{ item }}.conf.j2'
  30. dest: '/etc/nginx/conf.d/{{ item }}.conf'
  31. owner: 'root'
  32. group: 'root'
  33. mode: '0644'
  34. with_items:
  35. - 'status'
  36. notify:
  37. - 'Reload nginx'
  38. when: with_nginx
  39. - name: 'Install additional nginx configuration params (vhost_*)'
  40. template:
  41. src: 'nginx/vhost_{{ item }}.j2'
  42. dest: '/etc/nginx/vhost_{{ item }}'
  43. owner: 'root'
  44. group: 'root'
  45. mode: '0644'
  46. with_items:
  47. - 'all'
  48. - 'expires'
  49. - 'cache-fd'
  50. - 'protect-files'
  51. - 'security'
  52. notify:
  53. - 'Reload nginx'
  54. when: with_nginx
  55. - name: 'Create basic authentication file for admin (nginx)'
  56. template:
  57. src: 'nginx/auth_admin.j2'
  58. dest: '/etc/nginx/auth_admin'
  59. owner: 'root'
  60. group: 'www-data'
  61. mode: '0640'
  62. when: with_nginx
  63. - name: 'Install PHPMyAdmin virtual host for nginx (sites-available)'
  64. template:
  65. src: 'nginx/pma_vhost.j2'
  66. dest: '/etc/nginx/sites-available/pma'
  67. owner: 'root'
  68. group: 'root'
  69. mode: '0644'
  70. notify:
  71. - 'Reload nginx'
  72. when: with_phpmyadmin and with_nginx
  73. - name: 'Install PHPMyAdmin virtual host for nginx (sites-enabled)'
  74. file:
  75. src: '/etc/nginx/sites-available/pma'
  76. path: '/etc/nginx/sites-enabled/pma'
  77. state: 'link'
  78. notify:
  79. - 'Reload nginx'
  80. when: with_phpmyadmin and with_nginx
  81. - name: 'Install PHPPgAdmin virtual host for nginx (sites-available)'
  82. template:
  83. src: 'nginx/pga_vhost.j2'
  84. dest: '/etc/nginx/sites-available/pga'
  85. owner: 'root'
  86. group: 'root'
  87. mode: '0644'
  88. notify:
  89. - 'Reload nginx'
  90. when: with_phppgadmin and with_nginx
  91. - name: 'Install PHPPgAdmin virtual host for nginx (sites-enabled)'
  92. file:
  93. src: '/etc/nginx/sites-available/pga'
  94. path: '/etc/nginx/sites-enabled/pga'
  95. state: 'link'
  96. notify:
  97. - 'Reload nginx'
  98. when: with_phppgadmin and with_nginx
  99. - name: 'Install PHP system checks virtual host for nginx (sites-available)'
  100. template:
  101. src: 'nginx/sys_vhost.j2'
  102. dest: '/etc/nginx/sites-available/sys'
  103. owner: 'root'
  104. group: 'root'
  105. mode: '0644'
  106. notify:
  107. - 'Reload nginx'
  108. when: with_php and with_nginx
  109. - name: 'Install PHP system checks virtual host for nginx (sites-enabled)'
  110. file:
  111. src: '/etc/nginx/sites-available/sys'
  112. path: '/etc/nginx/sites-enabled/sys'
  113. state: 'link'
  114. notify:
  115. - 'Reload nginx'
  116. when: with_php and with_nginx
  117. - name: 'Ensure nginx is running'
  118. service:
  119. name: 'nginx'
  120. state: 'started'
  121. when: with_nginx