mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 18:29:21 +00:00 
			
		
		
		
	Solved certificate bug
This commit is contained in:
		| @@ -91,7 +91,7 @@ | ||||
|     bind_pw: "{{ ldap.bind_credential }}" | ||||
|     attributes: | ||||
|       objectClass: "{{ ldap.user_objects }}" | ||||
|       mail:         "{{ item.value.email }}" | ||||
|       mail:        "{{ item.value.email }}" | ||||
|     state: exact        # ‘exact’ is safest for single-valued attributes | ||||
|   loop: "{{ users | dict2items }}" | ||||
|   loop_control: | ||||
|   | ||||
| @@ -1,21 +0,0 @@ | ||||
| --- | ||||
| - name: "include task receive certbot certificate" | ||||
|   include_role:  | ||||
|     name: nginx-https-get-cert | ||||
|   vars: | ||||
|     domain: "{{item.source}}" | ||||
|   loop: "{{domain_mappings}}" | ||||
|  | ||||
| - name: The domains for which a www. redirect will be implemented | ||||
|   debug: | ||||
|     var: domain_mappings | ||||
|   when: enable_debug | bool | ||||
|  | ||||
| - name: configure nginx redirect configurations | ||||
|   vars: | ||||
|     item: "{{item}}" | ||||
|   template:  | ||||
|     src:  redirect.domain.nginx.conf.j2 | ||||
|     dest: "{{nginx.directories.http.servers}}{{item.source}}.conf" | ||||
|   loop:   "{{domain_mappings}}" | ||||
|   notify: restart nginx | ||||
| @@ -1,8 +0,0 @@ | ||||
| server { | ||||
|   {% set domain = item.source %} | ||||
|   {% set target = item.target %} | ||||
|   server_name {{domain}}; | ||||
|   {% include 'roles/letsencrypt/templates/ssl_header.j2' %} | ||||
|  | ||||
|   return 301 https://{{target}}$request_uri; | ||||
| } | ||||
							
								
								
									
										7
									
								
								roles/nginx-redirect-domains/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								roles/nginx-redirect-domains/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| --- | ||||
| - name: "Include domains redirects" | ||||
|   include_tasks: redirect-domain.yml | ||||
|   vars: | ||||
|     domain: "{{ item.source }}" | ||||
|     target: "{{ item.target }}" | ||||
|   loop: "{{domain_mappings}}" | ||||
							
								
								
									
										9
									
								
								roles/nginx-redirect-domains/tasks/redirect-domain.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								roles/nginx-redirect-domains/tasks/redirect-domain.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| - name: "include task receive certbot certificate" | ||||
|   include_role:  | ||||
|     name: nginx-https-get-cert | ||||
|  | ||||
| - name: configure nginx redirect configurations | ||||
|   template: | ||||
|     src:  redirect.domain.nginx.conf.j2 | ||||
|     dest: "{{ nginx.directories.http.servers }}{{ domain }}.conf" | ||||
|   notify: restart nginx | ||||
| @@ -0,0 +1,6 @@ | ||||
| server { | ||||
|   server_name {{ domain }}; | ||||
|   {% include 'roles/letsencrypt/templates/ssl_header.j2' %} | ||||
|  | ||||
|   return 301 https://{{ target }}$request_uri; | ||||
| } | ||||
| @@ -7,7 +7,7 @@ Automates the creation of Nginx server blocks that redirect all `www.` subdomain | ||||
| This role will: | ||||
| - **Discover** existing `*.conf` vhosts in your Nginx servers directory   | ||||
| - **Filter** domains with or without your `primary_domain`   | ||||
| - **Generate** redirect rules via the `nginx-redirect-domain` role   | ||||
| - **Generate** redirect rules via the `nginx-redirect-domains` role   | ||||
| - **Optionally** include a wildcard redirect template (experimental) ⭐️   | ||||
| - **Clean up** leftover configs when running in cleanup mode 🧹   | ||||
|  | ||||
| @@ -20,5 +20,5 @@ Ensure that any request to `www.example.com` automatically and permanently redir | ||||
| - **Auto-Discovery**: Scans your Nginx `servers` directory for `.conf` files. 🔍   | ||||
| - **Dynamic Redirects**: Builds `source: "www.domain"` → `target: "domain"` mappings on the fly. 🔧   | ||||
| - **Wildcard Redirect**: Includes a templated wildcard server block for `www.*` domains (toggleable). ✨   | ||||
| - **Cleanup Mode**: Removes the wildcard config file when `certbot_flavor` is set to `dedicated` and `mode_cleanup` is enabled. 🗑️   | ||||
| - **Cleanup Mode**: Removes the wildcard config file when `certbot_flavor` is set to `dedicated` and `mode_cleanup` is enabled. 🗑️ | ||||
| - **Debug Output**: Optional `enable_debug` gives detailed variable dumps for troubleshooting. 🐛   | ||||
|   | ||||
| @@ -8,9 +8,9 @@ | ||||
|   set_fact: | ||||
|     www_domains: "{{ all_domains | select('match', '^www\\.') | list }}" | ||||
|  | ||||
| - name: Include nginx-redirect-domain role for www-to-bare redirects | ||||
| - name: Include nginx-redirect-domains role for www-to-bare redirects | ||||
|   include_role: | ||||
|     name: nginx-redirect-domain | ||||
|     name: nginx-redirect-domains | ||||
|   vars: | ||||
|     domain_mappings: "{{ www_domains | ||||
|        | map('regex_replace', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user