2020-02-10 01:19:59 -06:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
2020-04-26 02:02:15 -05:00
|
|
|
- name: Install, configure, and start Apache and PHP
|
2020-02-10 01:19:59 -06:00
|
|
|
block:
|
2020-04-26 02:02:15 -05:00
|
|
|
- name: Install Apache and PHP packages
|
2020-02-10 01:19:59 -06:00
|
|
|
apt:
|
|
|
|
name: "{{ packages }}"
|
|
|
|
vars:
|
|
|
|
packages:
|
|
|
|
- apache2
|
2020-02-29 03:03:55 -06:00
|
|
|
- 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
|
2020-02-10 01:19:59 -06:00
|
|
|
- name: Copy configuration
|
|
|
|
copy:
|
|
|
|
src: "{{ item.src }}"
|
2020-04-26 02:02:15 -05:00
|
|
|
dest: "{{ phpdirs.files.0.path }}/{{ item.dest }}"
|
2020-02-10 01:19:59 -06:00
|
|
|
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
|
2020-02-10 01:19:59 -06:00
|
|
|
- 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
|
2020-02-20 03:49:06 -06:00
|
|
|
block:
|
2020-07-12 09:54:04 -05:00
|
|
|
- name: Disable modules
|
|
|
|
command:
|
|
|
|
argv:
|
2020-07-12 09:58:40 -05:00
|
|
|
- "/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:
|
2020-07-12 09:58:40 -05:00
|
|
|
- headers
|
2020-07-12 09:54:04 -05:00
|
|
|
- mpm_prefork
|
2020-07-12 09:58:40 -05:00
|
|
|
# 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
|
2020-02-10 01:19:59 -06:00
|
|
|
become: yes
|