@@ -0,0 +1,31 @@ | |||
--- | |||
apache_listen_ips: | |||
- 0.0.0.0:80 | |||
- 0.0.0.0:443 | |||
# A default virtualhost is included in Apache's configuration. | |||
# Set this to `true` to remove that default. | |||
apache_remove_default_vhost: false | |||
apache_mods_enabled: | |||
- rewrite | |||
- ssl | |||
apache_extra_mods_enabled: [] | |||
apache_mods_disabled: [] | |||
apache_state: started | |||
apache_service: apache2 | |||
apache_daemon: apache2 | |||
apache_daemon_path: /usr/sbin/ | |||
apache_server_root: /etc/apache2 | |||
apache_conf_path: /etc/apache2 | |||
apache_default_vhost_filename: 000-default.conf | |||
apache_packages: | |||
- apache2 | |||
- apache2-utils | |||
apache_extra_packages: [] |
@@ -0,0 +1,8 @@ | |||
--- | |||
- name: restart apache | |||
service: | |||
name: "{{apache_service}}" | |||
state: restarted | |||
when: apache_state != "stopped" | |||
@@ -0,0 +1,43 @@ | |||
--- | |||
- name: Install apache packages | |||
apt: | |||
name: "{{item}}" | |||
state: present | |||
loop: | |||
- "{{apache_packages}}" | |||
- "{{apache_extra_packages}}" | |||
- name: Configure Apache ip/port. | |||
template: | |||
src: ports.conf.j2 | |||
dest: "{{apache_server_root}}/ports.conf" | |||
notify: restart apache | |||
- name: Enable Apache mods. | |||
apache2_module: | |||
state: present | |||
name: "{{item}}" | |||
loop: "{{ apache_mods_enabled + apache_extra_mods_enabled }}" | |||
notify: restart apache | |||
- name: Disable Apache mods. | |||
apache2_module: | |||
state: absent | |||
name: "{{item}}" | |||
loop: "{{ apache_mods_disabled }}" | |||
notify: restart apache | |||
- name: Remove default vhost in sites-enabled. | |||
file: | |||
path: "{{ apache_conf_path }}/sites-enabled/{{ apache_default_vhost_filename }}" | |||
state: absent | |||
notify: restart apache | |||
when: apache_remove_default_vhost | |||
- name: Ensure Apache has selected state and enabled on boot. | |||
service: | |||
name: "{{ apache_service }}" | |||
state: "{{ apache_state }}" | |||
enabled: "{{ apache_state == 'started' }}" | |||
@@ -0,0 +1,6 @@ | |||
# If you just change the port or add more ports here, you will likely also | |||
# have to change the VirtualHost statement | |||
{% for ip in apache_listen_ips %} | |||
Listen {{ip}} | |||
{% endfor %} |