php.yml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. - name: 'Install common PHP dependencies (Debian <= 8)'
  2. apt:
  3. pkg: '{{ item }}'
  4. state: 'present'
  5. with_items:
  6. - 'php5-cli'
  7. - 'php5-curl'
  8. - 'php5-gd'
  9. - 'php5-intl'
  10. - 'php5-mcrypt'
  11. - 'php-mime-type'
  12. - 'php5-pgsql'
  13. - 'php5-sqlite'
  14. when: with_php and ansible_lsb.major_release|int <= 8
  15. tags:
  16. - 'web'
  17. - 'php'
  18. - name: 'Install common PHP dependencies (Debian >= 9)'
  19. apt:
  20. pkg: '{{ item }}'
  21. state: 'present'
  22. with_items:
  23. - 'php{{ php_version }}-cli'
  24. - 'php{{ php_version }}-curl'
  25. - 'php{{ php_version }}-gd'
  26. - 'php{{ php_version }}-intl'
  27. - 'php{{ php_version }}-mcrypt'
  28. - 'php{{ php_version }}-mysql'
  29. - 'php{{ php_version }}-pgsql'
  30. - 'php{{ php_version }}-sqlite3'
  31. when: with_php and ansible_lsb.major_release|int >= 9
  32. tags:
  33. - 'web'
  34. - 'php'
  35. - name: 'Create PHP log directory'
  36. file:
  37. path: '/var/log/php'
  38. state: directory
  39. owner: 'root'
  40. group: 'root'
  41. mode: '0755'
  42. when: with_fpm
  43. tags:
  44. - 'web'
  45. - 'php'
  46. - name: 'Install PHP configuration for syslog'
  47. template:
  48. src: '{{ item.src }}'
  49. dest: '{{ item.dest }}'
  50. owner: 'root'
  51. group: 'root'
  52. mode: '0644'
  53. with_items:
  54. - { src: 'rsyslog/php-errors.conf.j2', dest: '/etc/rsyslog.d/php-errors.conf' }
  55. - { src: 'logrotate/php-errors.j2', dest: '/etc/logrotate.d/php-errors' }
  56. notify:
  57. - 'Reload rsyslog for php'
  58. when: with_fpm
  59. tags:
  60. - 'web'
  61. - 'php'
  62. - name: 'Install local PHP configuration overrides for php5-cli (Debian 8)'
  63. template:
  64. src: 'php/php-config-cli.ini.j2'
  65. dest: '/etc/php5/cli/conf.d/99-local-config.ini'
  66. owner: 'root'
  67. group: 'root'
  68. mode: '0644'
  69. when: with_php and ansible_lsb.major_release|int == 8
  70. tags:
  71. - 'web'
  72. - 'php'
  73. - name: 'Install local PHP configuration overrides for php{{ php_version }}-cli (Debian >= 9)'
  74. template:
  75. src: 'php/php-config-cli.ini.j2'
  76. dest: '/etc/php/{{php_version }}/cli/conf.d/99-local-config.ini'
  77. owner: 'root'
  78. group: 'root'
  79. mode: '0644'
  80. when: with_php and ansible_lsb.major_release|int >= 9
  81. tags:
  82. - 'web'
  83. - 'php'
  84. - name: 'Install Apache2 module for php5'
  85. apt:
  86. pkg: 'libapache2-mod-php5'
  87. state: 'present'
  88. notify:
  89. - 'Reload apache2'
  90. when: with_modphp5
  91. tags:
  92. - 'web'
  93. - 'php'
  94. - name: 'Install Apache2 module for php{{ php_version }}'
  95. apt:
  96. pkg: 'libapache2-mod-php{{php_version}}'
  97. state: 'present'
  98. notify:
  99. - 'Reload apache2'
  100. when: with_modphp
  101. tags:
  102. - 'web'
  103. - 'php'
  104. - name: 'Install local PHP configuration (Debian < 8)'
  105. template:
  106. src: 'php/php-config-web.ini.j2'
  107. dest: '/etc/php5/conf.d/99-local-config.ini'
  108. owner: 'root'
  109. group: 'root'
  110. mode: '0644'
  111. notify:
  112. - 'Reload apache2'
  113. when: with_modphp5 and ansible_lsb.major_release|int < 8
  114. tags:
  115. - 'web'
  116. - 'php'
  117. - name: 'Install local PHP configuration for Apache 2 (Debian 8)'
  118. template:
  119. src: 'php/php-config-web.ini.j2'
  120. dest: '/etc/php5/apache2/conf.d/99-local-config.ini'
  121. owner: 'root'
  122. group: 'root'
  123. mode: '0644'
  124. notify:
  125. - 'Reload apache2'
  126. when: with_modphp5 and ansible_lsb.major_release|int == 8
  127. tags:
  128. - 'web'
  129. - 'php'
  130. - name: 'Install local PHP configuration for Apache 2 (Debian >= 9)'
  131. template:
  132. src: 'php/php-config-web.ini.j2'
  133. dest: '/etc/php/{{ php_version }}/apache2/conf.d/99-local-config.ini'
  134. owner: 'root'
  135. group: 'root'
  136. mode: '0644'
  137. notify:
  138. - 'Reload apache2'
  139. when: with_modphp and ansible_lsb.major_release|int >= 9
  140. tags:
  141. - 'web'
  142. - 'php'
  143. - name: 'Create system checks directory /etc/phpsyscheck'
  144. file:
  145. path: '/etc/phpsyscheck'
  146. state: 'directory'
  147. owner: 'root'
  148. group: 'root'
  149. mode: '0755'
  150. tags:
  151. - 'web'
  152. - 'php'
  153. - name: 'Install phpinfo system check'
  154. template:
  155. src: 'php/phpinfo.php'
  156. dest: '/etc/phpsyscheck/index.php'
  157. owner: 'root'
  158. group: 'root'
  159. mode: '0644'
  160. - name: 'Install PHP APC extension (Debian <= 8)'
  161. apt:
  162. pkg: 'php-apc'
  163. state: 'present'
  164. when: with_php_apc and ansible_lsb.major_release|int <= 8
  165. tags:
  166. - 'web'
  167. - 'php'
  168. - name: 'Install PHP APC extension (Debian >= 9)'
  169. apt:
  170. pkg: 'php-apcu'
  171. state: 'present'
  172. when: with_php_apc and ansible_lsb.major_release|int >= 9
  173. tags:
  174. - 'web'
  175. - 'php'
  176. - name: 'Install php-apc system check'
  177. template:
  178. src: 'php/apc.php'
  179. dest: '/etc/phpsyscheck/apc.php'
  180. owner: 'root'
  181. group: 'root'
  182. mode: '0644'
  183. when: with_php_apc
  184. tags:
  185. - 'web'
  186. - 'php'
  187. - name: 'Install MySQL extension for PHP - native driver (Debian 8)'
  188. apt:
  189. pkg: 'php5-mysqlnd'
  190. state: 'present'
  191. when: not with_php_mysql_legacy and ansible_lsb.major_release|int == 8
  192. tags:
  193. - 'web'
  194. - 'php'
  195. - name: 'Install MySQL extension for PHP (old driver)'
  196. apt:
  197. pkg: 'php5-mysql'
  198. state: 'present'
  199. when: with_php_mysql_legacy
  200. tags:
  201. - 'web'
  202. - 'php'
  203. - name: 'Install PHPMyAdmin'
  204. apt:
  205. pkg: 'phpmyadmin'
  206. state: 'present'
  207. when: with_phpmyadmin
  208. tags:
  209. - 'web'
  210. - 'php'
  211. - name: 'Install PHPPgAdmin'
  212. apt:
  213. pkg: 'phppgadmin'
  214. state: 'present'
  215. when: with_phppgadmin
  216. tags:
  217. - 'web'
  218. - 'php'
  219. - name: 'Install FPM for PHP 5 (Debian <= 8)'
  220. apt:
  221. pkg: 'php5-fpm'
  222. state: 'present'
  223. when: with_fpm and ansible_lsb.major_release|int <= 8
  224. tags:
  225. - 'web'
  226. - 'php'
  227. - name: 'Install FPM for PHP {{ php_version }} (Debian >= 9)'
  228. apt:
  229. pkg: 'php{{ php_version }}-fpm'
  230. state: 'present'
  231. when: with_fpm and ansible_lsb.major_release|int >= 9
  232. tags:
  233. - 'web'
  234. - 'php'
  235. - name: 'Configure FPM for PHP 5 (Debian <= 8)'
  236. lineinfile:
  237. dest: '/etc/php5/fpm/php-fpm.conf'
  238. regexp: '^{{item.key}}\s*=.*$'
  239. line: '{{item.key}} = {{item.value}}'
  240. insertafter: '^;{{item.key}}'
  241. with_items:
  242. - { key: 'error_log', value: 'syslog' }
  243. - { key: 'log_level', value: 'warning' }
  244. - { key: 'emergency_restart_threshold', value: '100' }
  245. - { key: 'emergency_restart_interval', value: '5s' }
  246. - { key: 'rlimit_files', value: '262144' }
  247. - { key: 'events.mechanism', value: 'epoll' }
  248. - { key: 'include', value: '/etc/php5/fpm/pool.d/local-pool.cnf' }
  249. notify:
  250. - 'Reload FPM for PHP 5'
  251. when: with_fpm and ansible_lsb.major_release|int <= 8
  252. tags:
  253. - 'web'
  254. - 'php'
  255. - name: 'Configure FPM for PHP {{ php_version }} (Debian >= 9)'
  256. lineinfile:
  257. dest: '/etc/php/{{ php_version }}/fpm/php-fpm.conf'
  258. regexp: '^{{item.key}}\s*=.*$'
  259. line: '{{item.key}} = {{item.value}}'
  260. insertafter: '^;{{item.key}}'
  261. with_items:
  262. - { key: 'error_log', value: 'syslog' }
  263. - { key: 'log_level', value: 'warning' }
  264. - { key: 'emergency_restart_threshold', value: '100' }
  265. - { key: 'emergency_restart_interval', value: '5s' }
  266. - { key: 'rlimit_files', value: '262144' }
  267. - { key: 'events.mechanism', value: 'epoll' }
  268. - { key: 'include', value: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf' }
  269. notify:
  270. - 'Reload FPM for PHP'
  271. when: with_fpm and ansible_lsb.major_release|int >= 9
  272. tags:
  273. - 'web'
  274. - 'php'
  275. - name: 'Install FPM pools configuration for PHP 5 (Debian <= 8)'
  276. template:
  277. src: 'fpm/php5-fpm-pools.conf.j2'
  278. dest: '/etc/php5/fpm/pool.d/local-pool.cnf'
  279. owner: 'root'
  280. group: 'root'
  281. mode: '0644'
  282. notify:
  283. - 'Reload FPM for PHP 5'
  284. when: with_fpm and ansible_lsb.major_release|int <= 8
  285. tags:
  286. - 'web'
  287. - 'php'
  288. - name: 'Install FPM pools configuration for PHP {{ php_version }} (Debian > 9)'
  289. template:
  290. src: 'fpm/php-fpm-pools.conf.j2'
  291. dest: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf'
  292. owner: 'root'
  293. group: 'root'
  294. mode: '0644'
  295. notify:
  296. - 'Reload FPM for PHP'
  297. when: with_fpm and ansible_lsb.major_release|int >= 9
  298. tags:
  299. - 'web'
  300. - 'php'
  301. - name: 'Install local PHP configuration overrides for php5-fpm (Debian 8)'
  302. template:
  303. src: 'php/php-config-web.ini.j2'
  304. dest: '/etc/php5/fpm/conf.d/99-local-config.ini'
  305. owner: 'root'
  306. group: 'root'
  307. mode: '0644'
  308. when: with_fpm and ansible_lsb.major_release|int == 8
  309. tags:
  310. - 'web'
  311. - 'php'
  312. - name: 'Install local PHP configuration overrides for php{{ php_version }}-fpm (Debian >= 9)'
  313. template:
  314. src: 'php/php-config-web.ini.j2'
  315. dest: '/etc/php/{{ php_version }}/fpm/conf.d/99-local-config.ini'
  316. owner: 'root'
  317. group: 'root'
  318. mode: '0644'
  319. when: with_fpm and ansible_lsb.major_release|int >= 9
  320. tags:
  321. - 'web'
  322. - 'php'
  323. - name: 'Install Nginx config files for PHP FPM (fpm servers pool)'
  324. template:
  325. src: 'fpm/nginx/fpm-pool.conf.j2'
  326. dest: '/etc/nginx/conf.d/fpm-pool.conf'
  327. owner: 'root'
  328. group: 'root'
  329. mode: '0644'
  330. notify:
  331. - 'Reload nginx'
  332. when: with_fpm and with_nginx
  333. tags:
  334. - 'web'
  335. - 'php'
  336. - name: 'Install Nginx config files for PHP FPM (fpm fastcgi config)'
  337. template:
  338. src: 'fpm/nginx/fastcgi_pass_fpm.j2'
  339. dest: '/etc/nginx/fastcgi_pass_fpm'
  340. owner: 'root'
  341. group: 'root'
  342. mode: '0644'
  343. notify:
  344. - 'Reload nginx'
  345. when: with_fpm and with_nginx
  346. tags:
  347. - 'web'
  348. - 'php'
  349. - name: 'Ensure FPM for PHP 5 is running (Debian <= 8)'
  350. service:
  351. name: 'php5-fpm'
  352. state: 'started'
  353. when: with_fpm and ansible_lsb.major_release|int <= 8
  354. tags:
  355. - 'web'
  356. - 'php'
  357. - name: 'Ensure FPM for PHP {{ php_version }} is running (Debian >= 9)'
  358. service:
  359. name: 'php{{ php_version }}-fpm'
  360. state: 'started'
  361. when: with_fpm and ansible_lsb.major_release|int >= 9
  362. tags:
  363. - 'web'
  364. - 'php'
  365. # vim: ft=yaml.ansible