#!/usr/bin/ansible-playbook # vim:ft=ansible: --- - name: Install, configure, and start Apache block: - name: Install Apache 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: Copy configuration copy: src: "{{ item.src }}" dest: "{{ item.dest }}" mode: "{{ item.mode }}" loop: - { src: "php-apache2.ini", dest: "/etc/php/7.2/apache2/php.ini", mode: "0644" } - { src: "php-cgi.ini", dest: "/etc/php/7.2/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: Enable modules block: - name: Enable rewrite command: "/usr/sbin/a2enmod rewrite" args: creates: /etc/apache2/mods-enabled/rewrite.load - name: Enable SSL command: "/usr/sbin/a2enmod ssl" args: creates: /etc/apache2/mods-enabled/ssl.load - name: Enable header modification command: "/usr/sbin/a2enmod headers" args: creates: /etc/apache2/mods-enabled/headers.load become: yes