From e8bf6b18c70a132d5f1cf6935e778ef7c3b5fe14 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 21 Jan 2025 16:18:35 +0100 Subject: [PATCH] Added README.md --- roles/nginx-docker-cert-deploy/README.md | 103 +++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 roles/nginx-docker-cert-deploy/README.md diff --git a/roles/nginx-docker-cert-deploy/README.md b/roles/nginx-docker-cert-deploy/README.md new file mode 100644 index 00000000..22d91ab2 --- /dev/null +++ b/roles/nginx-docker-cert-deploy/README.md @@ -0,0 +1,103 @@ +# Nginx Docker Cert Deploy Role + +🎉 **Author**: Kevin Veen-Birkenbach ([veen.world](https://www.veen.world)) + +This Ansible role simplifies the deployment of Let's Encrypt certificates into Docker Compose setups with Nginx. It ensures that certificates are copied, directories are created, and Nginx services are reloaded or restarted as needed. + +--- + +## 🚀 **Features** + +- Copies Let's Encrypt certificates to the target directory. +- Automatically reloads or restarts Nginx services in all Docker Compose containers. +- Configures and manages a `systemd` service for automated deployment. +- Supports periodic execution via a `systemd` timer. +- Handles dependent services like `systemd-notifier`. + +--- + +## 🔧 **Variables** + +The following variables can be customized: + +| Variable | Description | Default Value | +|-----------------------------------|------------------------------------------------|-----------------------------------------| +| `cert_mount_directory` | Target directory to mount certificates. | `{{docker_compose_instance_directory}}/certs/` | +| `nginx_docker_cert_deploy_script` | Path to the deployment script. | `{{path_administrator_scripts}}nginx-docker-cert-deploy.sh` | +| `docker_compose_project_name` | Name of the Docker Compose project. | None (must be defined in playbook) | +| `on_calendar_deploy_certificates` | `systemd` timer schedule for certificate updates. | None (must be defined in playbook) | + +--- + +## 📋 **Tasks Overview** + +### Main Tasks + +1. **Add Deployment Script**: + Copies the `nginx-docker-cert-deploy.sh` script to the administrator scripts directory. + +2. **Create Certificate Directory**: + Ensures the `cert_mount_directory` exists with proper permissions. + +3. **Configure Systemd Service**: + Deploys a `systemd` service file for the deployment process. + +4. **Include `systemd-timer` Role**: + Schedules automatic deployment tasks using a `systemd` timer. + +### Handlers + +- **Restart Service**: + Restarts the `nginx-docker-cert-deploy` service when configuration changes. + +--- + +## 📂 **File Structure** + +``` +roles/ + nginx-docker-cert-deploy/ + vars/ + main.yml + handlers/ + main.yml + files/ + nginx-docker-cert-deploy.sh + tasks/ + main.yml + templates/ + nginx-docker-cert-deploy.service.j2 + meta/ + main.yml +``` + +--- + +## 📖 **Usage Example** + +Here's an example of how to use this role in your playbook: + +```yaml +- name: Deploy Let's Encrypt certificates to Docker Compose + hosts: all + roles: + - role: nginx-docker-cert-deploy + vars: + domain: "example.com" + docker_compose_instance_directory: "/home/administrator/docker-compose/nginx" + docker_compose_project_name: "nginx" + on_calendar_deploy_certificates: "daily" +``` + +--- + +## 🛠️ **Dependencies** + +This role depends on: + +- `systemd-notifier`: Notifies about failures in the `systemd` service. + +--- + +Feel free to contribute, report issues, or suggest improvements! 😊 +