ansible/roles/apache-php/tasks/main.yml

77 lines
1.9 KiB
YAML
Raw Normal View History

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
2020-04-26 02:02:15 -05:00
- name: Install, configure, and start Apache and PHP
block:
2020-04-26 02:02:15 -05:00
- name: Install Apache and PHP packages
apt:
name: "{{ packages }}"
vars:
packages:
- apache2
- libapache2-mod-php
- php
- php-gd
- php-json
- php-mysql
- php-curl
- php-mbstring
- php-intl
- php-xml
- php-zip
- php-cgi
- php-cli
2020-07-23 23:13:16 -05:00
- python3-passlib # For htpasswd support
2020-04-26 02:02:15 -05:00
- name: Find PHP config directory
find:
paths: /etc/php
patterns: '*'
file_type: directory
register: phpdirs
- name: Debug
debug:
var: phpdirs.files.0.path
- name: Copy configuration
copy:
src: "{{ item.src }}"
2020-04-26 02:02:15 -05:00
dest: "{{ phpdirs.files.0.path }}/{{ item.dest }}"
mode: "{{ item.mode }}"
loop:
2020-04-26 02:02:15 -05:00
- { src: "php-apache2.ini", dest: "apache2/php.ini", mode: "0644" }
- { src: "php-cgi.ini", dest: "cgi/php.ini", mode: "0644" }
2020-10-18 23:23:00 -05:00
- name: Create includes directory
file: path=/etc/apache2/includes state=directory
- name: Disable default website
file:
# This is a symlink so who cares
path: "/etc/apache2/sites-enabled/000-default.conf"
state: absent
2020-07-12 09:54:04 -05:00
- name: Configure modules
block:
2020-07-12 09:54:04 -05:00
- name: Disable modules
command:
argv:
- "/usr/sbin/a2dismod"
2020-07-12 09:54:04 -05:00
- "{{ item }}"
removes: "/etc/apache2/mods-enabled/{{ item }}.load"
loop:
- mpm_event
notify: restart apache
- name: Enable modules
command:
argv:
- "/usr/sbin/a2enmod"
- "{{ item }}"
creates: "/etc/apache2/mods-enabled/{{ item }}.load"
loop:
- headers
2020-07-12 09:54:04 -05:00
- mpm_prefork
# Fun fact: this works
- php*
2020-10-18 23:23:00 -05:00
- proxy
- proxy_http
2020-07-12 09:54:04 -05:00
- rewrite
- ssl
notify: restart apache
become: yes