CI: pip install raus, molecule auf Runner vorinstalliert
Test & Deploy Hugo Docker CMS / test-and-deploy (push) Failing after 2m4s

This commit is contained in:
jonnybravo
2026-09-08 11:33:10 +02:00
parent 3ad8c9b5a6
commit 194d9d2ad2
6 changed files with 157 additions and 6 deletions
+24
View File
@@ -0,0 +1,24 @@
name: Test & Deploy Hugo Docker CMS
on:
push:
branches: [main]
jobs:
test-and-deploy:
runs-on: shell
steps:
- name: Molecule Test (Ubuntu Docker)
run: |
PATH="$HOME/.local/bin:$PATH"
cd ansible
molecule test
working-directory: /home/jonnybravo/Projekte/hugo_docker
- name: Deploy auf ras-dan-01
run: |
export SSH_AUTH_SOCK="$(ls -t /home/jonnybravo/.ssh/agent/s.*.agent.* 2>/dev/null | head -1)"
PATH="$HOME/.local/bin:$PATH"
cd ansible
ansible-playbook -i "ras-dan-01," deploy.yml
working-directory: /home/jonnybravo/Projekte/hugo_docker
+12 -6
View File
@@ -14,6 +14,7 @@
site_description: "Markdown-Dateien einfach in content/ ablegen."
site_author: "JonnyBravo"
deploy_path: "{{ '~' | expanduser }}/.docker/hugo"
project_root: "{{ playbook_dir }}/.."
tasks:
# ── Verzeichnisse anlegen ──
@@ -33,33 +34,33 @@
# ── docker-compose.yml kopieren ──
- name: docker-compose.yml kopieren
ansible.builtin.copy:
src: "../docker-compose.yml"
src: "{{ project_root }}/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/"
src: "{{ project_root }}/site/layouts/"
dest: "{{ deploy_path }}/site/layouts/"
mode: "0644"
- name: main.css kopieren
ansible.builtin.copy:
src: "../site/assets/css/main.css"
src: "{{ project_root }}/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"
src: "{{ project_root }}/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/"
src: "{{ project_root }}/crt/"
dest: "{{ deploy_path }}/crt/"
mode: "0600"
@@ -73,11 +74,12 @@
- "{{ target_hostname }}-chain.crt"
- "localhost.crt"
- "localhost-chain.crt"
ignore_errors: true
# ── Content (optional, nur wenn lokal vorhanden) ──
- name: Beispiel-Content kopieren (falls vorhanden)
ansible.builtin.copy:
src: "../content/"
src: "{{ project_root }}/content/"
dest: "{{ deploy_path }}/content/"
mode: "0644"
ignore_errors: true
@@ -102,6 +104,7 @@
chdir: "{{ deploy_path }}"
register: pull_result
changed_when: "'Pulled' in pull_result.stdout or 'newer' in pull_result.stdout"
when: molecule_test is not defined
- name: Docker Compose starten
ansible.builtin.command:
@@ -109,12 +112,14 @@
chdir: "{{ deploy_path }}"
register: compose_result
changed_when: "'Starting' in compose_result.stdout or 'Creating' in compose_result.stdout"
when: molecule_test is not defined
- name: Warten bis Caddy lauscht
ansible.builtin.wait_for:
port: "{{ target_port }}"
host: "127.0.0.1"
timeout: 30
when: molecule_test is not defined
- name: HTTPS-Smoke-Test
ansible.builtin.uri:
@@ -123,6 +128,7 @@
return_content: false
register: smoketest
failed_when: smoketest.status != 200
when: molecule_test is not defined
- name: Erfolgsmeldung
ansible.builtin.debug:
+3
View File
@@ -0,0 +1,3 @@
---
- name: Converge
ansible.builtin.import_playbook: ../../deploy.yml
+40
View File
@@ -0,0 +1,40 @@
---
driver:
name: docker
platforms:
- name: ubuntu
image: ubuntu:24.04
command: /bin/bash -c "while true; do sleep 3600; done"
tmpfs:
- /tmp
- /run
provisioner:
name: ansible
inventory:
host_vars:
ubuntu:
target_hostname: "test-node"
target_port: 5443
deploy_path: "/tmp/.docker/hugo"
project_root: "/home/jonnybravo/Projekte/hugo_docker"
molecule_test: true
config_options:
defaults:
host_key_checking: false
interpreter_python: auto_silent
verbosity: 1
verifier:
name: ansible
scenario:
test_sequence:
- syntax
- create
- prepare
- converge
- idempotence
- verify
- destroy
+10
View File
@@ -0,0 +1,10 @@
---
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Python und Abhängigkeiten installieren
ansible.builtin.raw: |
apt-get update -qq
apt-get install -y -qq python3 python3-pip sudo rsync
changed_when: false
+68
View File
@@ -0,0 +1,68 @@
---
- name: Verify
hosts: all
gather_facts: true
vars:
deploy_path: "/tmp/.docker/hugo"
tasks:
- name: Prüfe Verzeichnisstruktur
ansible.builtin.stat:
path: "{{ deploy_path }}/{{ item }}"
loop:
- content
- crt
- site/assets/css/main.css
- site/layouts/_default/baseof.html
- site/layouts/_default/list.html
- site/layouts/_default/rss.xml
- site/layouts/_default/single.html
- site/layouts/partials/footer.html
- site/layouts/partials/header.html
- site/layouts/partials/head.html
- site/layouts/partials/toc.html
- site/entrypoint.sh
- site/hugo.toml
- Caddyfile
- docker-compose.yml
register: file_check
- name: Alle Dateien müssen existieren
ansible.builtin.assert:
that: file_check.results | map(attribute='stat.exists') | list | min
fail_msg: "Fehlende Dateien im Deploy-Verzeichnis!"
success_msg: "Alle Dateien im Deploy-Verzeichnis vorhanden."
- name: Prüfe Entrypoint ausführbar
ansible.builtin.stat:
path: "{{ deploy_path }}/site/entrypoint.sh"
register: entrypoint_stat
- name: Entrypoint muss ausführbar sein
ansible.builtin.assert:
that: entrypoint_stat.stat.executable
fail_msg: "entrypoint.sh ist nicht ausführbar!"
success_msg: "entrypoint.sh ist ausführbar."
- name: Prüfe Template-Inhalte
ansible.builtin.shell: |
grep -q "test-node:5443" {{ deploy_path }}/site/hugo.toml
grep -q "test-node:5443" {{ deploy_path }}/Caddyfile
register: template_check
changed_when: false
- name: Templates müssen Hostname enthalten
ansible.builtin.assert:
that: template_check.rc == 0
fail_msg: "Templates enthalten nicht den Ziel-Hostnamen!"
success_msg: "Templates korrekt gerendert."
- name: Prüfe Zertifikatsdateien
ansible.builtin.stat:
path: "{{ deploy_path }}/crt/ca.crt"
register: ca_check
- name: CA-Zertifikat muss vorhanden sein
ansible.builtin.assert:
that: ca_check.stat.exists
fail_msg: "CA-Zertifikat fehlt!"
success_msg: "CA-Zertifikat vorhanden."