#!/usr/bin/ansible-playbook # vim:ft=ansible: --- - name: Install, configure, and start Apache and PHP block: - 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 - 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 }}" dest: "{{ phpdirs.files.0.path }}/{{ item.dest }}" mode: "{{ item.mode }}" loop: - { 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 - name: Configure modules block: - name: Disable modules command: argv: - "/usr/sbin/a2dismod" - "{{ 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 - mpm_prefork # Fun fact: this works - php* - rewrite - ssl notify: restart apache become: yes