mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-02-22 12:29:39 +01:00
Solved bugs and refactored
This commit is contained in:
parent
c7da4ddd8f
commit
62f9bab052
@ -4,7 +4,8 @@
|
|||||||
name: docker-central-database
|
name: docker-central-database
|
||||||
|
|
||||||
- name: "include tasks to receive attendize certbot certificate"
|
- name: "include tasks to receive attendize certbot certificate"
|
||||||
include_tasks: recieve-certbot-certificate.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
vars:
|
vars:
|
||||||
domain: "{{ item }}"
|
domain: "{{ item }}"
|
||||||
loop:
|
loop:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
- name: "include task certbot-and-globals.yml"
|
- name: "include role receive certbot certificate"
|
||||||
include_tasks: certbot-and-globals.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
|
|
||||||
- name: configure {{domain}}.conf
|
- name: configure {{domain}}.conf
|
||||||
template:
|
template:
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: docker-central-database
|
name: docker-central-database
|
||||||
|
|
||||||
- name: "include task certbot-and-globals.yml"
|
- name: "include role receive certbot certificate"
|
||||||
include_tasks: certbot-and-globals.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
vars:
|
vars:
|
||||||
domain: "{{domains.matrix_synapse}}"
|
domain: "{{domains.matrix_synapse}}"
|
||||||
http_port: "{{ports.localhost.http.matrix_synapse}}"
|
http_port: "{{ports.localhost.http.matrix_synapse}}"
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: docker-central-database
|
name: docker-central-database
|
||||||
|
|
||||||
- name: "include task certbot-and-globals.yml"
|
- name: "include role receive certbot certificate"
|
||||||
include_tasks: certbot-and-globals.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
|
|
||||||
- name: create nextcloud nginx proxy configuration file
|
- name: create nextcloud nginx proxy configuration file
|
||||||
template:
|
template:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
- name: "include task certbot-and-globals.yml"
|
- name: "include role receive certbot certificate"
|
||||||
include_tasks: certbot-and-globals.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
|
|
||||||
- name: configure {{domain}}.conf
|
- name: configure {{domain}}.conf
|
||||||
template:
|
template:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: "include task receive certbot certificate"
|
- name: "include task receive certbot certificate"
|
||||||
include_tasks: recieve-certbot-certificate.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
vars:
|
vars:
|
||||||
domain: "{{item.source}}"
|
domain: "{{item.source}}"
|
||||||
loop: "{{domain_mappings}}"
|
loop: "{{domain_mappings}}"
|
||||||
|
39
roles/nginx-https-recieve-certificate/README.md
Normal file
39
roles/nginx-https-recieve-certificate/README.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# Let's Encrypt Certificate Role
|
||||||
|
|
||||||
|
This Ansible role uses Certbot to obtain Let's Encrypt SSL/TLS certificates. It supports both dedicated and wildcard certificate requests based on domain conditions. It can also clean up (delete) dedicated certificates when cleanup mode is enabled.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Dedicated Certificate Request:**
|
||||||
|
Requests a certificate for a given domain using Certbot's `certonly` command with the webroot plugin.
|
||||||
|
|
||||||
|
- **Wildcard Certificate Request:**
|
||||||
|
When enabled, obtains a wildcard certificate for the primary domain (including both the primary domain and all its direct subdomains).
|
||||||
|
|
||||||
|
- **Certificate Cleanup:**
|
||||||
|
Provides an option to delete dedicated certificates if cleanup mode is active.
|
||||||
|
|
||||||
|
- **Run Once for Wildcard:**
|
||||||
|
Ensures that the wildcard certificate task runs only once to prevent duplicate requests.
|
||||||
|
|
||||||
|
## Tasks Overview
|
||||||
|
|
||||||
|
- **Receive Dedicated Certificate:**
|
||||||
|
Executes Certbot to request a dedicated certificate for `{{ domain }}` when a wildcard certificate is not applicable.
|
||||||
|
|
||||||
|
- **Receive Wildcard Certificate:**
|
||||||
|
Executes Certbot to request a wildcard certificate for `*{{ primary_domain }}` under the appropriate conditions.
|
||||||
|
|
||||||
|
- **Cleanup Dedicated Certificate:**
|
||||||
|
Runs Certbot's delete command to remove the dedicated certificate if cleanup mode is active.
|
||||||
|
|
||||||
|
- **Run Once Flag:**
|
||||||
|
Sets a fact to ensure that the wildcard certificate task is executed only once per playbook run.
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
This role is authored by [Kevin Veen-Birkenbach](https://www.veen.world).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Feel free to contribute or open issues if you have suggestions or encounter any problems with the role. Enjoy secure connections with Let's Encrypt and Ansible!
|
2
roles/nginx-https-recieve-certificate/meta/main.yml
Normal file
2
roles/nginx-https-recieve-certificate/meta/main.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- nginx-https
|
@ -1,2 +1,3 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
- health-nginx
|
- health-nginx
|
||||||
|
- nginx-global
|
||||||
|
@ -33,11 +33,15 @@
|
|||||||
notify: restart nginx
|
notify: restart nginx
|
||||||
when: run_once_nginx is not defined
|
when: run_once_nginx is not defined
|
||||||
|
|
||||||
- name: "include task certbot-and-globals.yml"
|
# Activated due to the reason that certificate management should be part of role nginx-https
|
||||||
include_tasks: certbot-and-globals.yml
|
# I don't know why this is activated here.
|
||||||
vars:
|
# Propably solved on 2025-02-15 . Please remove latest on 2025-12-31 if no errors appear or earlier
|
||||||
domain: "{{primary_domain}}"
|
#
|
||||||
when: run_once_nginx is not defined
|
#- name: "include task certbot-and-globals.yml"
|
||||||
|
# include_tasks: certbot-and-globals.yml
|
||||||
|
# vars:
|
||||||
|
# domain: "{{primary_domain}}"
|
||||||
|
# when: run_once_nginx is not defined
|
||||||
|
|
||||||
- name: flush nginx service
|
- name: flush nginx service
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
- name: "include task receive certbot certificate"
|
|
||||||
include_tasks: recieve-certbot-certificate.yml
|
|
||||||
|
|
||||||
- name: Load global Nginx Configuration
|
|
||||||
include_role:
|
|
||||||
name: nginx-global
|
|
@ -1,5 +1,6 @@
|
|||||||
- name: "include task certbot-and-globals.yml"
|
- name: "include role receive certbot certificate"
|
||||||
include_tasks: certbot-and-globals.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
|
|
||||||
- name: "include task create-domain-conf.yml"
|
- name: "include task create-domain-conf.yml"
|
||||||
include_tasks: create-domain-conf.yml
|
include_tasks: create-domain-conf.yml
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
- name: "include task certbot-and-globals.yml"
|
- name: "include role receive certbot certificate"
|
||||||
include_tasks: certbot-and-globals.yml
|
include_role:
|
||||||
|
name: nginx-https-recieve-certificate
|
||||||
|
|
||||||
- name: "include task create-domain-conf.yml"
|
- name: "include task create-domain-conf.yml"
|
||||||
include_tasks: create-domain-conf.yml
|
include_tasks: create-domain-conf.yml
|
||||||
|
Loading…
x
Reference in New Issue
Block a user