php.yml 11 KB

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