mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Renamed server roles by osi they work on
This commit is contained in:
35
roles/srv-proxy-6-6-domain/README.md
Normal file
35
roles/srv-proxy-6-6-domain/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Nginx Domain Setup 🚀
|
||||
|
||||
## Description
|
||||
|
||||
This role bootstraps **per-domain Nginx configuration**: it requests TLS certificates, applies global modifiers, deploys a ready-made vHost file, and can optionally lock down access via OAuth2.
|
||||
|
||||
## Overview
|
||||
|
||||
A higher-level orchestration wrapper, *srv-proxy-6-6-domain* ties together several lower-level roles:
|
||||
|
||||
1. **`srv-web-7-7-inj-compose`** – applies global tweaks and includes.
|
||||
2. **`srv-web-6-6-tls-core`** – obtains Let’s Encrypt certificates.
|
||||
3. **Domain template deployment** – copies a Jinja2 vHost from *srv-proxy-7-4-core*.
|
||||
4. **`web-app-oauth2-proxy`** *(optional)* – protects the site with OAuth2.
|
||||
|
||||
The result is a complete, reproducible domain rollout in a single playbook task.
|
||||
|
||||
## Purpose
|
||||
|
||||
Provide **one-stop, idempotent domain provisioning** for Nginx-based homelabs or small production environments.
|
||||
|
||||
## Features
|
||||
|
||||
- **End-to-end TLS** — certificate retrieval and secure headers included.
|
||||
- **Template-driven vHosts** — choose *basic* or *ws_generic* flavours (or your own).
|
||||
- **Conditional OAuth2** — easily toggle authentication per application.
|
||||
- **Handler-safe** — automatically triggers an Nginx reload when templates change.
|
||||
- **Composable** — designed to be called repeatedly for many domains.
|
||||
|
||||
## Credits 📝
|
||||
|
||||
Developed and maintained by **Kevin Veen-Birkenbach**.
|
||||
Learn more at <https://www.veen.world>
|
||||
|
||||
Part of the **CyMaIS Project** — licensed under the [CyMaIS NonCommercial License (CNCL)](https://s.veen.world/cncl)
|
5
roles/srv-proxy-6-6-domain/defaults/main.yml
Normal file
5
roles/srv-proxy-6-6-domain/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
# default vhost flavour
|
||||
vhost_flavour: "basic" # valid: basic | ws_generic
|
||||
|
||||
# build the full template path from the flavour
|
||||
vhost_template_src: "roles/srv-proxy-7-4-core/templates/vhost/{{ vhost_flavour }}.conf.j2"
|
27
roles/srv-proxy-6-6-domain/meta/main.yml
Normal file
27
roles/srv-proxy-6-6-domain/meta/main.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Automated domain provisioning (TLS, vHost, OAuth2) for Nginx."
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Archlinux
|
||||
versions:
|
||||
- rolling
|
||||
galaxy_tags:
|
||||
- nginx
|
||||
- tls
|
||||
- letsencrypt
|
||||
- oauth2
|
||||
- automation
|
||||
- archlinux
|
||||
repository: https://s.veen.world/cymais
|
||||
issue_tracker_url: https://s.veen.world/cymaisissues
|
||||
documentation: https://s.veen.world/cymais
|
||||
dependencies:
|
||||
- srv-proxy-7-4-core
|
36
roles/srv-proxy-6-6-domain/tasks/main.yml
Normal file
36
roles/srv-proxy-6-6-domain/tasks/main.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
- name: "include role for {{domain}} to receive certificates and do the modification routines"
|
||||
include_role:
|
||||
name: srv-web-7-6-composer
|
||||
|
||||
- name: "Copy nginx config to {{ configuration_destination }}"
|
||||
template:
|
||||
src: "{{ vhost_template_src }}"
|
||||
dest: "{{ configuration_destination }}"
|
||||
register: nginx_conf
|
||||
notify: restart nginx
|
||||
|
||||
- name: "Check if {{ domains | get_domain(application_id) }} is reachable (only if config unchanged)"
|
||||
uri:
|
||||
url: "{{ domains | get_url(application_id, web_protocol) }}"
|
||||
register: site_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
when: not nginx_conf.changed
|
||||
|
||||
- name: Restart nginx if site is down
|
||||
command:
|
||||
cmd: "true"
|
||||
notify: restart nginx
|
||||
when:
|
||||
- not nginx_conf.changed
|
||||
- site_check.status is defined
|
||||
- not site_check.status in [200,301,302]
|
||||
|
||||
- name: "set oauth2_proxy_application_id (Needed due to lazzy loading issue)"
|
||||
set_fact:
|
||||
oauth2_proxy_application_id: "{{ application_id }}"
|
||||
when: applications | is_feature_enabled('oauth2',application_id)
|
||||
|
||||
- name: "include the web-app-oauth2-proxy role {{domain}}"
|
||||
include_tasks: "{{ playbook_dir }}/roles/web-app-oauth2-proxy/tasks/main.yml"
|
||||
when: applications | is_feature_enabled('oauth2',application_id)
|
1
roles/srv-proxy-6-6-domain/vars/main.yml
Normal file
1
roles/srv-proxy-6-6-domain/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
configuration_destination: "{{nginx.directories.http.servers}}{{domain}}.conf"
|
Reference in New Issue
Block a user