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

70 lines
1.7 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-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" }
- 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/a2enmod"
- "{{ 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:
- mpm_prefork
- rewrite
- ssl
- headers
notify: restart apache
become: yes