Merge branch 'upstream'

Conflicts:
	tasks/configure-Debian.yml
	tasks/configure-RedHat.yml
This commit is contained in:
Rasmus Werling 2016-01-29 08:10:33 +02:00
commit 6a2d44d1c7
8 changed files with 36 additions and 8 deletions

View file

@ -8,6 +8,8 @@ An Ansible Role that installs Apache 2.x on RHEL/CentOS and Debian/Ubuntu.
If you are using SSL/TLS, you will need to provide your own certificate and key files. You can generate a self-signed certificate with a command like `openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout example.key -out example.crt`.
If you are using Apache with PHP, I recommend using the `geerlingguy.php` role to install PHP, and you can either use mod_php (by adding the proper package, e.g. `libapache2-mod-php5` for Ubuntu, to `php_packages`), or by also using `geerlingguy.apache-php-fpm` to connect Apache to PHP via FPM. See that role's README for more info.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
@ -105,6 +107,10 @@ The list of packages to be installed. This defaults to a set of platform-specifi
Set initial Apache daemon state to be enforced when this role is run. This should generally remain `started`, but you can set it to `stopped` if you need to fix the Apache config during a playbook run or otherwise would not like Apache started at the time this role is run.
apache_ignore_missing_ssl_certificate: true
If you would like to only create SSL vhosts when the vhost certificate is present (e.g. when using Lets Encrypt), set `apache_ignore_missing_ssl_certificate` to `false`. When doing this, you might need to run your playbook more than once so all the vhosts are configured (if another part of the playbook generates the SSL certificates).
## Dependencies
None.

View file

@ -33,6 +33,8 @@ apache_vhosts_ssl: []
# # Optional.
# certificate_chain_file: "/path/to/certificate_chain.crt"
apache_ignore_missing_ssl_certificate: true
apache_ssl_protocol: "All -SSLv2 -SSLv3"
apache_ssl_cipher_suite: "AES256+EECDH:AES256+EDH"

View file

@ -23,10 +23,10 @@
with_items: apache_mods_disabled
notify: restart apache
- name: Add htpasswd configuration.
htpasswd: path={{ item.file }} name={{ item.username }} password={{ item.password }} state=present
with_items: apache_htpasswd
when: apache_htpasswd
- name: Check whether certificates defined in vhosts exist.
stat: path={{ item.certificate_file }}
register: apache_ssl_certificates
with_items: apache_vhosts_ssl
- name: Add apache vhosts configuration.
template:

View file

@ -8,10 +8,10 @@
with_items: apache_ports_configuration_items
notify: restart apache
- name: Add htpasswd configuration.
htpasswd: path={{ item.file }} name={{ item.username }} password={{ item.password }} state=present
with_items: apache_htpasswd
when: apache_htpasswd
- name: Check whether certificates defined in vhosts exist.
stat: path={{ item.certificate_file }}
register: apache_ssl_certificates
with_items: apache_vhosts_ssl
- name: Add apache vhosts configuration.
template:

View file

@ -11,11 +11,14 @@
ServerAlias {{ vhost.serveralias|join(' ') }}
{% endif %}
{% endif %}
{% if vhost.documentroot is defined %}
DocumentRoot {{ vhost.documentroot }}
{% endif %}
{% if vhost.serveradmin is defined %}
ServerAdmin {{ vhost.serveradmin }}
{% endif %}
{% if vhost.documentroot is defined %}
<Directory "{{ vhost.documentroot }}">
AllowOverride All
Options -Indexes FollowSymLinks
@ -29,6 +32,7 @@
Allow from all
{% endif %}
</Directory>
{% endif %}
{% if vhost.extra_parameters is defined %}
{{ vhost.extra_parameters }}
{% endif %}
@ -43,7 +47,9 @@
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}
{% endif %}
{% if vhost.documentroot is defined %}
DocumentRoot {{ vhost.documentroot }}
{% endif %}
SSLEngine on
SSLCipherSuite {{ apache_ssl_cipher_suite }}
@ -58,12 +64,14 @@
{% if vhost.serveradmin is defined %}
ServerAdmin {{ vhost.serveradmin }}
{% endif %}
{% if vhost.documentroot is defined %}
<Directory "{{ vhost.documentroot }}">
AllowOverride All
Options -Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
{% endif %}
{% if vhost.extra_parameters is defined %}
{{ vhost.extra_parameters }}
{% endif %}

View file

@ -11,11 +11,14 @@
ServerAlias {{ vhost.serveralias|join(' ') }}
{% endif %}
{% endif %}
{% if vhost.documentroot is defined %}
DocumentRoot {{ vhost.documentroot }}
{% endif %}
{% if vhost.serveradmin is defined %}
ServerAdmin {{ vhost.serveradmin }}
{% endif %}
{% if vhost.documentroot is defined %}
<Directory "{{ vhost.documentroot }}">
AllowOverride All
Options -Indexes +FollowSymLinks
@ -28,6 +31,7 @@
Require all granted
{% endif %}
</Directory>
{% endif %}
{% if vhost.extra_parameters is defined %}
{{ vhost.extra_parameters }}
{% endif %}
@ -37,12 +41,15 @@
{# Set up SSL VirtualHosts #}
{% for vhost in apache_vhosts_ssl %}
{% if apache_ignore_missing_ssl_certificate or apache_ssl_certificates.results[loop.index0].stat.exists %}
<VirtualHost *:{{ apache_listen_port_ssl }}>
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}
{% endif %}
{% if vhost.documentroot is defined %}
DocumentRoot {{ vhost.documentroot }}
{% endif %}
SSLEngine on
SSLCipherSuite {{ apache_ssl_cipher_suite }}
@ -58,14 +65,17 @@
{% if vhost.serveradmin is defined %}
ServerAdmin {{ vhost.serveradmin }}
{% endif %}
{% if vhost.documentroot is defined %}
<Directory "{{ vhost.documentroot }}">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
{% endif %}
{% if vhost.extra_parameters is defined %}
{{ vhost.extra_parameters }}
{% endif %}
</VirtualHost>
{% endif %}
{% endfor %}

View file

@ -1,4 +1,5 @@
FROM ubuntu:12.04
RUN apt-get update
# Install Ansible
RUN apt-get install -y software-properties-common python-software-properties git

View file

@ -1,4 +1,5 @@
FROM ubuntu:14.04
RUN apt-get update
# Install Ansible
RUN apt-get install -y software-properties-common git