diff --git a/README.md b/README.md index c754f69..fc3f470 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ There are similar list of objects supported by Nagios like: The list vhosts contains at least one virtual host to configure Apache2. ```yaml - - vhost_name: nagios4.example.org + - vhostname: nagios4.example.org serveradmin: webmaster@example.org vhost_aliases: nagios.example.org ssl_certificate_file: "/etc/letsencrypt/live/nagios4.example.org/fullchain.pem" diff --git a/tasks/configure_apache.yml b/tasks/configure_apache.yml index bab8018..f26d04f 100644 --- a/tasks/configure_apache.yml +++ b/tasks/configure_apache.yml @@ -1,7 +1,7 @@ --- - name: Ensure configuration file is available to Apache template: - dest: "/etc/apache2/sites-available/25-{{ item.vhost_name }}.conf" + dest: "/etc/apache2/sites-available/25-{{ item.vhostname }}.conf" src: templates/apache_vhost.j2 mode: 0644 backup: yes @@ -19,7 +19,7 @@ - name: Ensure vhost is enabled file: state: link - src: "/etc/apache2/sites-available/25-{{ item.vhost_name }}.conf" - path: "/etc/apache2/sites-enabled/25-{{ item.vhost_name }}.conf" + src: "/etc/apache2/sites-available/25-{{ item.vhostname }}.conf" + path: "/etc/apache2/sites-enabled/25-{{ item.vhostname }}.conf" loop: "{{ vhosts }}" - notify: Restart Apache2 \ No newline at end of file + notify: Restart Apache2 diff --git a/templates/apache_vhost.j2 b/templates/apache_vhost.j2 index 295e759..26f21f8 100644 --- a/templates/apache_vhost.j2 +++ b/templates/apache_vhost.j2 @@ -1,14 +1,14 @@ - ServerName {{ item.vhost_name }} - ServerAdmin {{ item.webadmin | default('webmaster@' + item.vhost_name) }} + ServerName {{ item.vhostname }} + ServerAdmin {{ item.webadmin | default('webmaster@' + item.vhostname) }} {% if item.vhost_aliases is defined %} ServerAlias {{ item.vhost_aliases }} {% endif %} ## Logging - ErrorLog "/var/log/apache2/{{ item.vhost_name }}_error_ssl.log" + ErrorLog "/var/log/apache2/{{ item.vhostname }}_error_ssl.log" ServerSignature Off - CustomLog "/var/log/apache2/{{ item.vhost_name }}_access_ssl.log" combined + CustomLog "/var/log/apache2/{{ item.vhostname }}_access_ssl.log" combined ErrorDocument 404 https://susurrando.com/notfound.php ErrorDocument 500 https://susurrando.com/error500.php ErrorDocument 503 https://susurrando.com/error503.php @@ -94,13 +94,13 @@ - ServerName {{ item.vhost_name }} + ServerName {{ item.vhostname }} ServerAdmin {{ item.webadmin }} ## Logging - ErrorLog "/var/log/apache2/{{ item.vhost_name }}_ssl_error_ssl.log" + ErrorLog "/var/log/apache2/{{ item.vhostname }}_ssl_error_ssl.log" ServerSignature Off - CustomLog "/var/log/apache2/{{ item.vhost_name }}_ssl_access_ssl.log" combined + CustomLog "/var/log/apache2/{{ item.vhostname }}_ssl_access_ssl.log" combined ErrorDocument 404 https://susurrando.com/notfound.php ErrorDocument 500 https://susurrando.com/error500.php ErrorDocument 503 https://susurrando.com/error503.php @@ -125,6 +125,6 @@ SSLProxyEngine On SSLProxyCheckPeerCN on SSLProxyCheckPeerExpire on - ProxyPass / http://{{ item.vhost_name }}/ - ProxyPassReverse / http://{{ item.vhost_name }}/ - \ No newline at end of file + ProxyPass / http://{{ item.vhostname }}/ + ProxyPassReverse / http://{{ item.vhostname }}/ +