updated apache role to function with ansibleguy.infra_django_apache
This commit is contained in:
		
							parent
							
								
									b0f520c8b5
								
							
						
					
					
						commit
						71f6b4c022
					
				|  | @ -0,0 +1,3 @@ | ||||||
|  | # These are supported funding model platforms | ||||||
|  | 
 | ||||||
|  | patreon: ansibleguy | ||||||
|  | @ -60,7 +60,7 @@ default_apache: | ||||||
|     # 'Header set Permissions-Policy': '"none"' |     # 'Header set Permissions-Policy': '"none"' | ||||||
|     # 'Header set Content-Security-Policy': '"default-src https:; font-src https:; img-src https:; script-src https:; style-src https:;"' |     # 'Header set Content-Security-Policy': '"default-src https:; font-src https:; img-src https:; script-src https:; style-src https:;"' | ||||||
| 
 | 
 | ||||||
|   ssl: |   ssl:  # see: https://github.com/ansibleguy/infra_certs | ||||||
|     path: '/etc/apache2/ssl' |     path: '/etc/apache2/ssl' | ||||||
|     ca: |     ca: | ||||||
|       file:  # can be used if you want to use an existing ca |       file:  # can be used if you want to use an existing ca | ||||||
|  | @ -85,6 +85,9 @@ default_apache: | ||||||
|     email: |     email: | ||||||
|     renew: false  # if a renewal should be started by the role; the renewal service will auto-renew the certificates otherwise |     renew: false  # if a renewal should be started by the role; the renewal service will auto-renew the certificates otherwise | ||||||
| 
 | 
 | ||||||
|  |   security: | ||||||
|  |     restricted_methods: ['GET', 'POST', 'HEAD'] | ||||||
|  | 
 | ||||||
| APACHE_CONFIG: "{{ default_apache | combine(apache, recursive=true) }}" | APACHE_CONFIG: "{{ default_apache | combine(apache, recursive=true) }}" | ||||||
| 
 | 
 | ||||||
| # site-specific config | # site-specific config | ||||||
|  | @ -94,6 +97,7 @@ default_site_config: | ||||||
|   admin: 'apache@template.ansibleguy.net' |   admin: 'apache@template.ansibleguy.net' | ||||||
|   port_plain: 80 |   port_plain: 80 | ||||||
|   port_ssl: 443 |   port_ssl: 443 | ||||||
|  |   domain: | ||||||
|   aliases: [] |   aliases: [] | ||||||
|   ip: |   ip: | ||||||
| 
 | 
 | ||||||
|  | @ -114,7 +118,7 @@ default_site_config: | ||||||
|   serve: |   serve: | ||||||
|     path: '/var/www/html' |     path: '/var/www/html' | ||||||
| 
 | 
 | ||||||
|   ssl: |   ssl:  # see: https://github.com/ansibleguy/infra_certs | ||||||
|     mode: 'selfsigned'  # existing/selfsigned/ca/letsencrypt |     mode: 'selfsigned'  # existing/selfsigned/ca/letsencrypt | ||||||
|     # existing: |     # existing: | ||||||
|     #   We expect the certs to be placed in the role's 'files' directory named like the site |     #   We expect the certs to be placed in the role's 'files' directory named like the site | ||||||
|  | @ -182,4 +186,3 @@ apache_config_graylist: [ | ||||||
|     'SSLEngine', 'SSLCertificateKeyFile', 'SSLCertificateFile', 'SSLCertificateChainFile', 'ErrorLog', 'CustomLog', 'ServerAdmin', |     'SSLEngine', 'SSLCertificateKeyFile', 'SSLCertificateFile', 'SSLCertificateChainFile', 'ErrorLog', 'CustomLog', 'ServerAdmin', | ||||||
|     'ServerAlias', 'ServerName', 'Redirect' |     'ServerAlias', 'ServerName', 'Redirect' | ||||||
| ] | ] | ||||||
| apache_restricted_methods: ['GET', 'POST', 'HEAD'] |  | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
|   ansible.builtin.fail: |   ansible.builtin.fail: | ||||||
|     msg: "The required site-configuration was not provided! |     msg: "The required site-configuration was not provided! | ||||||
|     Needed: 'domain'" |     Needed: 'domain'" | ||||||
|   when: site.domain is undefined |   when: site.domain is none or site.domain is undefined | ||||||
|   tags: [config, sites, certs] |   tags: [config, sites, certs] | ||||||
| 
 | 
 | ||||||
| - name: "Apache | Debian | Site '{{ name }}' | Configuring certificates" | - name: "Apache | Debian | Site '{{ name }}' | Configuring certificates" | ||||||
|  |  | ||||||
|  | @ -113,6 +113,7 @@ | ||||||
|   vars: |   vars: | ||||||
|     site: "{{ default_site_config | combine(site_item.value, recursive=true) }}" |     site: "{{ default_site_config | combine(site_item.value, recursive=true) }}" | ||||||
|     name: "{{ site_item.key | safe_key }}" |     name: "{{ site_item.key | safe_key }}" | ||||||
|  |     path: "{{ site.serve.path }}" | ||||||
|   loop_control: |   loop_control: | ||||||
|     loop_var: site_item |     loop_var: site_item | ||||||
|   with_dict: "{{ APACHE_CONFIG.sites }}" |   with_dict: "{{ APACHE_CONFIG.sites }}" | ||||||
|  | @ -131,9 +132,11 @@ | ||||||
|   vars: |   vars: | ||||||
|     site: "{{ default_site_config | combine(site_item.value, recursive=true) }}" |     site: "{{ default_site_config | combine(site_item.value, recursive=true) }}" | ||||||
|     name: "{{ site_item.key | safe_key }}" |     name: "{{ site_item.key | safe_key }}" | ||||||
|  |     path: "{{ site.serve.path }}" | ||||||
|   loop_control: |   loop_control: | ||||||
|     loop_var: site_item |     loop_var: site_item | ||||||
|   with_dict: "{{ APACHE_CONFIG.sites }}" |   with_dict: "{{ APACHE_CONFIG.sites }}" | ||||||
|  |   no_log: true | ||||||
|   tags: [config, sites, certs] |   tags: [config, sites, certs] | ||||||
| 
 | 
 | ||||||
| - name: Apache | Debian | Starting/Enabling apache | - name: Apache | Debian | Starting/Enabling apache | ||||||
|  |  | ||||||
|  | @ -113,11 +113,11 @@ | ||||||
| {% if site.security.restrict_methods %} | {% if site.security.restrict_methods %} | ||||||
|   <IfModule mod_rewrite.c> |   <IfModule mod_rewrite.c> | ||||||
|     RewriteEngine On |     RewriteEngine On | ||||||
|     RewriteCond %{REQUEST_METHOD} ^(?!{% for method in apache_restricted_methods %}{{ method }}{% if not loop.last %}|{% endif %}{% endfor %}) |     RewriteCond %{REQUEST_METHOD} ^(?!{% for method in APACHE_CONFIG.security.restricted_methods %}{{ method }}{% if not loop.last %}|{% endif %}{% endfor %}) | ||||||
|     RewriteRule .* - [F] |     RewriteRule .* - [F] | ||||||
|   </IfModule> |   </IfModule> | ||||||
|   <Directory /> |   <Directory /> | ||||||
|     <LimitExcept {% for method in apache_restricted_methods %}{{ method }} {% endfor %}> |     <LimitExcept {% for method in APACHE_CONFIG.security.restricted_methods %}{{ method }} {% endfor %}> | ||||||
|       deny from all |       deny from all | ||||||
|     </LimitExcept> |     </LimitExcept> | ||||||
|   </Directory> |   </Directory> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue