self-hosting/roles/setup_apache2/tasks/main.yml

40 lines
935 B
YAML

---
- name: Install apache
become: true
ansible.builtin.apt:
name: apache2
state: present
notify: Start apache2 service
- name: Remove default html dir
become: true
ansible.builtin.file:
path: /var/www/html
state: absent
- name: Check if default vHost is enabled
ansible.builtin.stat:
path: /etc/apache2/sites-enabled/000-default.conf
register: enabled_default_vhost
- name: Disable default vHost
become: true
ansible.builtin.command: a2dissite 000-default.conf
when: enabled_default_vhost.stat.exists
notify: Reload apache2 service
- name: Remove default vHost conf files
become: true
ansible.builtin.file:
path: "/etc/apache2/sites-available/{{ item }}"
state: absent
with_items:
- 000-default.conf
- default-ssl.conf
- name: Create /var/www/empty for *:80 vHosts
become: true
ansible.builtin.file:
path: /var/www/empty
state: directory
mode: 0755