CI: pip install raus, molecule auf Runner vorinstalliert
Test & Deploy Hugo Docker CMS / test-and-deploy (push) Failing after 2m4s
Test & Deploy Hugo Docker CMS / test-and-deploy (push) Failing after 2m4s
This commit is contained in:
@@ -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
@@ -14,6 +14,7 @@
|
|||||||
site_description: "Markdown-Dateien einfach in content/ ablegen."
|
site_description: "Markdown-Dateien einfach in content/ ablegen."
|
||||||
site_author: "JonnyBravo"
|
site_author: "JonnyBravo"
|
||||||
deploy_path: "{{ '~' | expanduser }}/.docker/hugo"
|
deploy_path: "{{ '~' | expanduser }}/.docker/hugo"
|
||||||
|
project_root: "{{ playbook_dir }}/.."
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
# ── Verzeichnisse anlegen ──
|
# ── Verzeichnisse anlegen ──
|
||||||
@@ -33,33 +34,33 @@
|
|||||||
# ── docker-compose.yml kopieren ──
|
# ── docker-compose.yml kopieren ──
|
||||||
- name: docker-compose.yml kopieren
|
- name: docker-compose.yml kopieren
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "../docker-compose.yml"
|
src: "{{ project_root }}/docker-compose.yml"
|
||||||
dest: "{{ deploy_path }}/docker-compose.yml"
|
dest: "{{ deploy_path }}/docker-compose.yml"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
# ── Statische Site-Dateien kopieren ──
|
# ── Statische Site-Dateien kopieren ──
|
||||||
- name: Hugo-Layouts kopieren
|
- name: Hugo-Layouts kopieren
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "../site/layouts/"
|
src: "{{ project_root }}/site/layouts/"
|
||||||
dest: "{{ deploy_path }}/site/layouts/"
|
dest: "{{ deploy_path }}/site/layouts/"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
- name: main.css kopieren
|
- name: main.css kopieren
|
||||||
ansible.builtin.copy:
|
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"
|
dest: "{{ deploy_path }}/site/assets/css/main.css"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
- name: Entrypoint kopieren und ausführbar machen
|
- name: Entrypoint kopieren und ausführbar machen
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "../site/entrypoint.sh"
|
src: "{{ project_root }}/site/entrypoint.sh"
|
||||||
dest: "{{ deploy_path }}/site/entrypoint.sh"
|
dest: "{{ deploy_path }}/site/entrypoint.sh"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
# ── Zertifikate kopieren ──
|
# ── Zertifikate kopieren ──
|
||||||
- name: Zertifikate für Ziel-Host kopieren
|
- name: Zertifikate für Ziel-Host kopieren
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "../crt/"
|
src: "{{ project_root }}/crt/"
|
||||||
dest: "{{ deploy_path }}/crt/"
|
dest: "{{ deploy_path }}/crt/"
|
||||||
mode: "0600"
|
mode: "0600"
|
||||||
|
|
||||||
@@ -73,11 +74,12 @@
|
|||||||
- "{{ target_hostname }}-chain.crt"
|
- "{{ target_hostname }}-chain.crt"
|
||||||
- "localhost.crt"
|
- "localhost.crt"
|
||||||
- "localhost-chain.crt"
|
- "localhost-chain.crt"
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
# ── Content (optional, nur wenn lokal vorhanden) ──
|
# ── Content (optional, nur wenn lokal vorhanden) ──
|
||||||
- name: Beispiel-Content kopieren (falls vorhanden)
|
- name: Beispiel-Content kopieren (falls vorhanden)
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "../content/"
|
src: "{{ project_root }}/content/"
|
||||||
dest: "{{ deploy_path }}/content/"
|
dest: "{{ deploy_path }}/content/"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
@@ -102,6 +104,7 @@
|
|||||||
chdir: "{{ deploy_path }}"
|
chdir: "{{ deploy_path }}"
|
||||||
register: pull_result
|
register: pull_result
|
||||||
changed_when: "'Pulled' in pull_result.stdout or 'newer' in pull_result.stdout"
|
changed_when: "'Pulled' in pull_result.stdout or 'newer' in pull_result.stdout"
|
||||||
|
when: molecule_test is not defined
|
||||||
|
|
||||||
- name: Docker Compose starten
|
- name: Docker Compose starten
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
@@ -109,12 +112,14 @@
|
|||||||
chdir: "{{ deploy_path }}"
|
chdir: "{{ deploy_path }}"
|
||||||
register: compose_result
|
register: compose_result
|
||||||
changed_when: "'Starting' in compose_result.stdout or 'Creating' in compose_result.stdout"
|
changed_when: "'Starting' in compose_result.stdout or 'Creating' in compose_result.stdout"
|
||||||
|
when: molecule_test is not defined
|
||||||
|
|
||||||
- name: Warten bis Caddy lauscht
|
- name: Warten bis Caddy lauscht
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
port: "{{ target_port }}"
|
port: "{{ target_port }}"
|
||||||
host: "127.0.0.1"
|
host: "127.0.0.1"
|
||||||
timeout: 30
|
timeout: 30
|
||||||
|
when: molecule_test is not defined
|
||||||
|
|
||||||
- name: HTTPS-Smoke-Test
|
- name: HTTPS-Smoke-Test
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
@@ -123,6 +128,7 @@
|
|||||||
return_content: false
|
return_content: false
|
||||||
register: smoketest
|
register: smoketest
|
||||||
failed_when: smoketest.status != 200
|
failed_when: smoketest.status != 200
|
||||||
|
when: molecule_test is not defined
|
||||||
|
|
||||||
- name: Erfolgsmeldung
|
- name: Erfolgsmeldung
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
ansible.builtin.import_playbook: ../../deploy.yml
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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."
|
||||||
Reference in New Issue
Block a user