self-hosting/roles/apache-install/tasks/main.yml

42 lines
883 B
YAML
Raw Normal View History

2021-10-31 13:04:40 +01:00
---
2022-03-12 16:35:32 +01:00
- name: Install apache
become: true
2021-10-31 13:04:40 +01:00
apt:
2022-03-12 16:35:32 +01:00
name: apache2
2021-10-31 13:04:40 +01:00
state: present
update_cache: yes
2022-03-12 16:35:32 +01:00
notify: Restart apache2 service
2022-03-12 16:56:39 +01:00
- name: Remove default html dir
become: true
file:
path: /var/www/html
state: absent
2022-03-12 19:00:14 +01:00
2022-03-12 20:06:23 +01:00
- name: Check if defautl vHost is enabled
stat:
path: /etc/apache2/sites-enabled/000-default.conf
register: enabled_default_vhost
- name: Disable default vHost
2022-03-12 19:39:45 +01:00
become: true
command: a2dissite 000-default.conf
2022-03-12 20:06:23 +01:00
when: enabled_default_vhost.stat.exists
2022-03-12 19:39:45 +01:00
notify: Restart apache2 service
- name: Remove default vHost conf files
become: true
file:
path: "/etc/apache2/sites-available/{{ item }}"
state: absent
with_items:
- 000-default.conf
- default-ssl.conf
notify: Restart apache2 service
2022-03-12 19:00:14 +01:00
- name: Create /var/www/empty for *:80 vHosts
become: true
file:
path: /var/www/empty
state: directory