updated setting/header overwrite

This commit is contained in:
AnsibleGuy 2021-12-06 23:55:45 +01:00
parent 813ac53193
commit cb57621b33
3 changed files with 18 additions and 6 deletions

View File

@ -62,6 +62,13 @@ This will also be done automatically if no domain is supplied.
* **Warning:** Not every setting/variable you provide will be checked for validity. Bad config might break the role! * **Warning:** Not every setting/variable you provide will be checked for validity. Bad config might break the role!
* **Warning:** If you run a web application you might need to disable the 'Content-Security-Policy' header!
* **Info:** To disable default settings and headers => just set their value to: ''
## Requirements ## Requirements
* Community collection and certificate role: ```ansible-galaxy install -r requirements.yml``` * Community collection and certificate role: ```ansible-galaxy install -r requirements.yml```

View File

@ -187,3 +187,4 @@ apache_config_graylist: [
'ServerAlias', 'ServerName', 'Redirect' 'ServerAlias', 'ServerName', 'Redirect'
] ]
force_removal: false force_removal: false
NONE_VALUES: [none, '', ' ']

View File

@ -66,7 +66,7 @@
{% if APACHE_CONFIG.config | length > 0 %} {% if APACHE_CONFIG.config | length > 0 %}
# global config # global config
{% for setting, value in APACHE_CONFIG.config.items() %} {% for setting, value in APACHE_CONFIG.config.items() %}
{% if setting not in apache_config_graylist %} {% if setting not in apache_config_graylist and value not in NONE_VALUES %}
{{ setting }} {{ value }} {{ setting }} {{ value }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
@ -75,7 +75,7 @@
{% if site.config | length > 0 %} {% if site.config | length > 0 %}
# site-specific config # site-specific config
{% for setting, value in site.config.items() %} {% for setting, value in site.config.items() %}
{% if setting not in apache_config_graylist %} {% if setting not in apache_config_graylist and value not in NONE_VALUES %}
{{ setting }} {{ value }} {{ setting }} {{ value }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
@ -85,10 +85,12 @@
# global headers # global headers
<IfModule mod_headers.c> <IfModule mod_headers.c>
{% for header, value in APACHE_CONFIG.headers.items() %} {% for header, value in APACHE_CONFIG.headers.items() %}
{% if 'Header' in header %} {% if header not in site.headers and value not in NONE_VALUES %}
{% if 'Header' in header %}
{{ header }} {{ value }} {{ header }} {{ value }}
{% else %} {% else %}
Header set {{ header }} {{ value }} Header set {{ header }} {{ value }}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
@ -99,10 +101,12 @@
# site-specific headers # site-specific headers
<IfModule mod_headers.c> <IfModule mod_headers.c>
{% for header, value in site.headers.items() %} {% for header, value in site.headers.items() %}
{% if 'Header' in header %} {% if value not in NONE_VALUES %}
{% if 'Header' in header %}
{{ header }} {{ value }} {{ header }} {{ value }}
{% else %} {% else %}
Header set {{ header }} {{ value }} Header set {{ header }} {{ value }}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}