first
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
---
|
||||
# Playbook: Hugo-Docker-CMS aufzielen
|
||||
# Aufruf: ansible-playbook -i "<host>," deploy.yml
|
||||
# oder mit Variablen:
|
||||
# ansible-playbook -i "<host>," deploy.yml -e "target_hostname=ras-dan-01 target_port=5443"
|
||||
|
||||
- name: Hugo Docker CMS bereitstellen
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
vars:
|
||||
target_hostname: "{{ inventory_hostname }}"
|
||||
target_port: 5443
|
||||
site_title: "Hugo Docker CMS"
|
||||
site_description: "Markdown-Dateien einfach in content/ ablegen."
|
||||
site_author: "JonnyBravo"
|
||||
deploy_path: "{{ '~' | expanduser }}/.docker/hugo"
|
||||
|
||||
tasks:
|
||||
# ── Verzeichnisse anlegen ──
|
||||
- name: Zielverzeichnisse erstellen
|
||||
ansible.builtin.file:
|
||||
path: "{{ deploy_path }}/{{ item }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop:
|
||||
- content
|
||||
- crt
|
||||
- site/assets/css
|
||||
- site/layouts/_default
|
||||
- site/layouts/partials
|
||||
- site/static
|
||||
|
||||
# ── docker-compose.yml kopieren ──
|
||||
- name: docker-compose.yml kopieren
|
||||
ansible.builtin.copy:
|
||||
src: "../docker-compose.yml"
|
||||
dest: "{{ deploy_path }}/docker-compose.yml"
|
||||
mode: "0644"
|
||||
|
||||
# ── Statische Site-Dateien kopieren ──
|
||||
- name: Hugo-Layouts kopieren
|
||||
ansible.builtin.copy:
|
||||
src: "../site/layouts/"
|
||||
dest: "{{ deploy_path }}/site/layouts/"
|
||||
mode: "0644"
|
||||
|
||||
- name: main.css kopieren
|
||||
ansible.builtin.copy:
|
||||
src: "../site/assets/css/main.css"
|
||||
dest: "{{ deploy_path }}/site/assets/css/main.css"
|
||||
mode: "0644"
|
||||
|
||||
- name: Entrypoint kopieren und ausführbar machen
|
||||
ansible.builtin.copy:
|
||||
src: "../site/entrypoint.sh"
|
||||
dest: "{{ deploy_path }}/site/entrypoint.sh"
|
||||
mode: "0755"
|
||||
|
||||
# ── Zertifikate kopieren ──
|
||||
- name: Zertifikate für Ziel-Host kopieren
|
||||
ansible.builtin.copy:
|
||||
src: "../crt/"
|
||||
dest: "{{ deploy_path }}/crt/"
|
||||
mode: "0600"
|
||||
|
||||
- name: Zertifikate lesbar machen (crt-Dateien)
|
||||
ansible.builtin.file:
|
||||
path: "{{ deploy_path }}/crt/{{ item }}"
|
||||
mode: "0644"
|
||||
loop:
|
||||
- "ca.crt"
|
||||
- "{{ target_hostname }}.crt"
|
||||
- "{{ target_hostname }}-chain.crt"
|
||||
- "localhost.crt"
|
||||
- "localhost-chain.crt"
|
||||
|
||||
# ── Content (optional, nur wenn lokal vorhanden) ──
|
||||
- name: Beispiel-Content kopieren (falls vorhanden)
|
||||
ansible.builtin.copy:
|
||||
src: "../content/"
|
||||
dest: "{{ deploy_path }}/content/"
|
||||
mode: "0644"
|
||||
ignore_errors: true
|
||||
|
||||
# ── Templates rendern ──
|
||||
- name: Caddyfile aus Template generieren
|
||||
ansible.builtin.template:
|
||||
src: "templates/Caddyfile.j2"
|
||||
dest: "{{ deploy_path }}/Caddyfile"
|
||||
mode: "0644"
|
||||
|
||||
- name: hugo.toml aus Template generieren
|
||||
ansible.builtin.template:
|
||||
src: "templates/hugo.toml.j2"
|
||||
dest: "{{ deploy_path }}/site/hugo.toml"
|
||||
mode: "0644"
|
||||
|
||||
# ── Docker Compose starten ──
|
||||
- name: Docker Compose Pull (neueste Images)
|
||||
ansible.builtin.command:
|
||||
cmd: docker compose pull
|
||||
chdir: "{{ deploy_path }}"
|
||||
register: pull_result
|
||||
changed_when: "'Pulled' in pull_result.stdout or 'newer' in pull_result.stdout"
|
||||
|
||||
- name: Docker Compose starten
|
||||
ansible.builtin.command:
|
||||
cmd: docker compose up -d
|
||||
chdir: "{{ deploy_path }}"
|
||||
register: compose_result
|
||||
changed_when: "'Starting' in compose_result.stdout or 'Creating' in compose_result.stdout"
|
||||
|
||||
- name: Warten bis Caddy lauscht
|
||||
ansible.builtin.wait_for:
|
||||
port: "{{ target_port }}"
|
||||
host: "127.0.0.1"
|
||||
timeout: 30
|
||||
|
||||
- name: HTTPS-Smoke-Test
|
||||
ansible.builtin.uri:
|
||||
url: "https://localhost:{{ target_port }}/"
|
||||
validate_certs: false
|
||||
return_content: false
|
||||
register: smoketest
|
||||
failed_when: smoketest.status != 200
|
||||
|
||||
- name: Erfolgsmeldung
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
- "✅ Hugo Docker CMS läuft!"
|
||||
- " https://{{ target_hostname }}:{{ target_port }}/"
|
||||
- " https://localhost:{{ target_port }}/"
|
||||
- " Pfad: {{ deploy_path }}"
|
||||
- " .md-Dateien: {{ deploy_path }}/content/"
|
||||
- ""
|
||||
- "🔒 CA-Zertifikat muss noch vertraut werden (auf deinem Client):"
|
||||
- " sudo cp {{ playbook_dir }}/../crt/ca.crt /etc/ca-certificates/trust-source/anchors/hugo-docker-ca.crt"
|
||||
- " sudo update-ca-trust"
|
||||
@@ -0,0 +1,5 @@
|
||||
library=
|
||||
name=NSS Internal PKCS #11 Module
|
||||
parameters=configdir='sql:' certPrefix='' keyPrefix='' secmod='secmod.db' flags= updatedir='' updateCertPrefix='' updateKeyPrefix='' updateid='' updateTokenDescription=''
|
||||
NSS=Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[ECC,RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30})
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{# Template: Caddyfile für Ziel-Host #}
|
||||
https://{{ target_hostname }}:{{ target_port }} {
|
||||
tls /etc/caddy/certs/{{ target_hostname }}.crt /etc/caddy/certs/{{ target_hostname }}.key
|
||||
reverse_proxy hugo:1313
|
||||
}
|
||||
{% if target_hostname != 'localhost' %}
|
||||
https://localhost:{{ target_port }} {
|
||||
tls /etc/caddy/certs/localhost.crt /etc/caddy/certs/localhost.key
|
||||
reverse_proxy hugo:1313
|
||||
}
|
||||
{% endif %}
|
||||
@@ -0,0 +1,32 @@
|
||||
{# Template: hugo.toml für Ziel-Host #}
|
||||
# Hugo 0.165+ — moderne Konfiguration
|
||||
baseURL = "https://{{ target_hostname }}:{{ target_port }}/"
|
||||
locale = "de"
|
||||
title = "{{ site_title }}"
|
||||
enableGitInfo = false
|
||||
disableFastRender = true
|
||||
|
||||
[markup]
|
||||
[markup.highlight]
|
||||
style = "catppuccin-mocha"
|
||||
noClasses = false
|
||||
lineNos = false
|
||||
[markup.goldmark]
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = true
|
||||
|
||||
[taxonomies]
|
||||
tag = "tags"
|
||||
|
||||
[outputs]
|
||||
home = ["HTML", "RSS"]
|
||||
page = ["HTML"]
|
||||
|
||||
[params]
|
||||
description = "{{ site_description }}"
|
||||
author = "{{ site_author }}"
|
||||
images = []
|
||||
|
||||
buildDrafts = false
|
||||
buildFuture = false
|
||||
buildExpired = false
|
||||
Reference in New Issue
Block a user