mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-04 12:18:17 +00:00 
			
		
		
		
	Nginx Docker Cert Deploy Role
🎉 Author: Kevin Veen-Birkenbach
This Ansible role simplifies the deployment of Let's Encrypt certificates into Docker Compose setups with Nginx. It supports both individual certificates per subdomain and a single wildcard certificate for all subdomains.
🚀 Features
- Automatically deploys Let's Encrypt certificates to Docker Compose setups.
 - Supports both single-domain certificates and one wildcard certificate for all subdomains.
 - Copies certificates to the target directory inside the container.
 - Automatically reloads or restarts Nginx services when certificates are updated.
 - Configures and manages a 
systemdservice for automated certificate deployment. - Includes a 
systemdtimer for scheduled renewals. - Handles dependent services like 
alert-compose. 
🔧 Tasks Overview
1️⃣ Main Tasks
- 
Add Deployment Script
- Copies 
srv-proxy-6-6-tls-deploy.shto the administrator scripts directory. 
 - Copies 
 - 
Create Certificate Directory
- Ensures 
cert_mount_directoryexists with proper permissions. 
 - Ensures 
 - 
Configure
systemdService- Deploys a 
systemdservice file for the deployment process. 
 - Deploys a 
 - 
Include
gen-timerRole- Schedules automatic certificate deployment using a 
systemdtimer. 
 - Schedules automatic certificate deployment using a 
 
2️⃣ Handlers
- Restart Nginx Service
- Restarts 
srv-proxy-6-6-tls-deploywhenever a certificate update occurs. 
 - Restarts 
 
🔧 Deploying Certificates into Docker Containers
The role automates copying certificates into Docker Compose setups.
1️⃣ Deployment Script (srv-proxy-6-6-tls-deploy.sh)
This script:
- Copies certificates to the correct container directory.
 - Reloads Nginx inside all running containers.
 - Restarts containers if needed.
 
Usage:
sh srv-proxy-6-6-tls-deploy.sh primary_domain /path/to/docker/compose
🎯 Summary
| Feature | Description | 
|---|---|
| Single-domain & wildcard support | Use individual certs or a wildcard certificate | 
| Automated renewal | Cronjob or systemd timer ensures auto-renewals | 
| Docker-ready | Deploys certificates directly into Docker containers | 
| Supports Nginx & Mailu | Compatible with multiple services | 
| Systemd integration | Automates deployment via systemd | 
🚀 Now your Nginx setup is fully automated and secured with Let's Encrypt! 🎉