rename dmc12 inventory to cloudlorean and vault admin_password
- replace inventory/dmc12.yml with cloudlorean.yml (+ group_vars) and update all README/AGENTS call examples and the inventory table - move admin_password hash into encrypted vault.yml; remove plaintext copies from roles/bootstrap/defaults and group_vars/external.yml - bootstrap.yml loads vault.yml via vars_files (same pattern as monitoring) - monitoring: PSK config/registration updates, docker role defaults, os-updates logging/reboot refinements, ansible.cfg/execute.sh tweaks - add .project-wiki knowledge base and .github agent instructions
This commit is contained in:
@@ -29,7 +29,7 @@ werden:
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml --vault-password-file .vault_pass bootstrap.yml
|
||||
ansible-playbook -i inventory/cloudlorean.yml --vault-password-file .vault_pass bootstrap.yml
|
||||
```
|
||||
|
||||
## Funktionsweise
|
||||
@@ -66,7 +66,7 @@ Handler neu gestartet.
|
||||
| Variable | Typ | Default | Beschreibung |
|
||||
|-------------------------|----------|-------------------|-----------------------------------------------------|
|
||||
| `admin_authorized_keys` | list | siehe `defaults/` | Liste von `{ key, comment }`-Einträgen für `admin` |
|
||||
| `admin_password` | string | siehe `defaults/` | SHA-512-Hash des Admin-Passworts |
|
||||
| `admin_password` | string | – (Vault) | SHA-512-Hash des Admin-Passworts; liegt verschlüsselt in `vault.yml` und wird von `bootstrap.yml` per `vars_files` geladen |
|
||||
|
||||
### Steuer-Variablen (keine Defaults, optional setzen)
|
||||
|
||||
@@ -78,7 +78,7 @@ Handler neu gestartet.
|
||||
|
||||
`admin_authorized_keys` wird auch pro Inventory in `group_vars/external.yml`
|
||||
überschrieben. Der Handler `Restart sshd` verwendet `ssh_service_name`, sofern
|
||||
gesetzt (z. B. `ssh` für `gitea`/`ipam` in `inventory/dmc12.yml`).
|
||||
gesetzt (z. B. `ssh` für `gitea`/`ipam` in `inventory/cloudlorean.yml`).
|
||||
|
||||
## Templates
|
||||
|
||||
@@ -102,7 +102,7 @@ gesetzt (z. B. `ssh` für `gitea`/`ipam` in `inventory/dmc12.yml`).
|
||||
Teile, z. B.:
|
||||
|
||||
```bash
|
||||
ansible-playbook bootstrap.yml -i inventory/dmc12.yml -t ssh
|
||||
ansible-playbook bootstrap.yml -i inventory/cloudlorean.yml -t ssh
|
||||
```
|
||||
|
||||
## Abhängigkeiten
|
||||
|
||||
@@ -9,5 +9,5 @@ admin_authorized_keys:
|
||||
- key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA+EvtGavPlXfv7b00jSYsXX2+IEsqFWupEs6Rzf5z9q root@ansible"
|
||||
comment: "Generic Ansible Key"
|
||||
|
||||
# Admin user password (hashed with SHA-512)
|
||||
admin_password: "$6$NmIxM3ZbJDsbC1E6$BO8ag1ZyBqbhELjk0ppKV0CLnYXhHDp9oZc.jmkc62N9hjwbXihF1FmvsYgMKKINVcwaE73u2dRO8pnE6yEGH/"
|
||||
# admin_password lives encrypted in vault.yml (loaded via vars_files in
|
||||
# bootstrap.yml); no plaintext fallback per repository vault policy.
|
||||
|
||||
@@ -29,7 +29,7 @@ Einbindung per `import_role`:
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml playbooks/docker.yml
|
||||
ansible-playbook -i inventory/cloudlorean.yml playbooks/docker.yml
|
||||
```
|
||||
|
||||
## Funktionsweise
|
||||
@@ -52,7 +52,7 @@ ansible-playbook -i inventory/dmc12.yml playbooks/docker.yml
|
||||
| Variable | Typ | Default | Beschreibung |
|
||||
|----------------------|---------|--------------------------------------|-------------------------------------------------------|
|
||||
| `docker_mirror` | string | `https://download.docker.com/linux/debian` | Basis-URL des Docker-APT-Repositories |
|
||||
| `os_version_codename`| string | `{{ ansible_lsb.codename }}` | Codename der Distribution (für `Suites:`) |
|
||||
| `os_version_codename`| string | `{{ ansible_facts['distribution_release'] }}` | Codename der Distribution (für `Suites:`) |
|
||||
| `docker_packages` | list | siehe unten | Liste der zu installierenden Docker-Pakete |
|
||||
|
||||
Default `docker_packages`:
|
||||
@@ -67,7 +67,8 @@ docker_packages:
|
||||
```
|
||||
|
||||
`os_version_codename` wird standardmäßig automatisch anhand von
|
||||
`ansible_lsb.codename` ermittelt und kann bei Bedarf überschrieben werden.
|
||||
`ansible_facts['distribution_release']` ermittelt und kann bei Bedarf
|
||||
überschrieben werden.
|
||||
|
||||
## Templates
|
||||
|
||||
@@ -99,4 +100,4 @@ Die Rolle vergibt keine eigenen Tags. Bei Bedarf über das Playbook steuerbar.
|
||||
- Der Handler `Start Docker` aktiviert und startet den Service, ohne bereits
|
||||
laufende Container zu beeinflussen.
|
||||
- Wird die Rolle innerhalb von `bootstrap` aufgerufen, übernimmt das Top-Level
|
||||
Playbook das `become`/`user`-Handling.
|
||||
Playbook das `become`/`user`-Handling.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
docker_mirror: https://download.docker.com/linux/debian
|
||||
os_version_codename: "{{ ansible_lsb.codename }}"
|
||||
os_version_codename: "{{ ansible_facts['distribution_release'] }}"
|
||||
docker_packages:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-buildx-plugin
|
||||
- docker-compose-plugin
|
||||
- docker-compose-plugin
|
||||
|
||||
@@ -26,7 +26,7 @@ Template und zieht stets die neuesten Images (`pull: always`).
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml playbooks/upgrade-hawser.yml
|
||||
ansible-playbook -i inventory/cloudlorean.yml playbooks/upgrade-hawser.yml
|
||||
```
|
||||
|
||||
## Funktionsweise
|
||||
|
||||
@@ -28,7 +28,7 @@ Rolle eingebunden und wird in der Regel nicht separat aufgerufen:
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml playbooks/os-updates-deb.yml
|
||||
ansible-playbook -i inventory/cloudlorean.yml playbooks/os-updates-deb.yml
|
||||
```
|
||||
|
||||
## Funktionsweise
|
||||
|
||||
@@ -23,7 +23,7 @@ erwünschte ("Good") Keys hinzu und entfernt unerwünschte ("Bad") Keys aus der
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml playbooks/hardening/manage-ssh-keys.yml
|
||||
ansible-playbook -i inventory/cloudlorean.yml playbooks/hardening/manage-ssh-keys.yml
|
||||
```
|
||||
|
||||
Good/Bad-Keys können per Inventory überschrieben oder über Umgebungsvariablen
|
||||
|
||||
+23
-14
@@ -27,7 +27,7 @@ einschließlich Template-Verlinkung.
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml --vault-password-file .vault_password \
|
||||
ansible-playbook -i inventory/cloudlorean.yml --vault-password-file .vault_password \
|
||||
playbooks/monitoring.yml
|
||||
```
|
||||
|
||||
@@ -50,14 +50,16 @@ Tag `monitoring`):
|
||||
anlegen, `docker.conf` aus Template ausliefern. Falls nein: Plugin-Config
|
||||
entfernen.
|
||||
5. **`configure-psk.yml`** – stellt PSK-Store auf dem Controller sicher
|
||||
(`<playbook_dir>/../.zabbix-psk`), generiert pro Host eine PSK mit
|
||||
(im Repository unter `.zabbix-psk`), generiert pro Host eine PSK mit
|
||||
`openssl rand -hex`, persistiert sie im Store und verteilt sie auf den
|
||||
Zielhost (`/etc/zabbix/zabbix_agent2.psk`, Mode `0600`).
|
||||
6. **`configure-agent.yml`** – schreibt `zabbix_agent2.conf` aus Template.
|
||||
7. **`register-host.yml`** – registriert bzw. aktualisiert den Host über die
|
||||
Zabbix-API (`community.zabbix.zabbix_host`). Verknüpft Standard-Templates
|
||||
und ggf. Docker-Templates. Unterscheidet zwischen Proxy- und
|
||||
Server-Modus (zwei Tasks, gegeneinander exklusiv). Delegiert an localhost.
|
||||
Zabbix-API (`community.zabbix.zabbix_host` via `httpapi`-Connection).
|
||||
Verknüpft Standard-Templates und ggf. Docker-Templates. Wählt
|
||||
`monitored_by: proxy` bzw. `zabbix_server` anhand von
|
||||
`monitoring_zabbix_proxy`.
|
||||
Delegiert an localhost.
|
||||
|
||||
## Variablen
|
||||
|
||||
@@ -92,10 +94,10 @@ Tag `monitoring`):
|
||||
|-----------------------------------------|--------|--------------------------------------|---------------------------------------------------------|
|
||||
| `monitoring_zabbix_tls_connect` | string | `psk` | TLS-Modus für ausgehende Verbindungen |
|
||||
| `monitoring_zabbix_tls_accept` | string | `psk` | TLS-Modus für eingehende Verbindungen |
|
||||
| `monitoring_zabbix_psk_identity` | string | `{{ inventory_hostname }}` | PSK-Identity (hostname) |
|
||||
| `monitoring_zabbix_psk_identity` | string | `{{ monitoring_zabbix_host_name }}` | PSK-Identity; muss mit der in Zabbix registrierten Identity übereinstimmen |
|
||||
| `monitoring_zabbix_psk_file` | string | `/etc/zabbix/zabbix_agent2.psk` | Pfad zur PSK-Datei auf dem Zielhost |
|
||||
| `monitoring_zabbix_psk_bits` | int | `256` | PSK-Länge in Bits (32 Byte → 64 Hex-Chars) |
|
||||
| `monitoring_zabbix_psk_store` | string | `{{ playbook_dir }}/../.zabbix-psk` | PSK-Store-Verzeichnis auf dem Controller |
|
||||
| `monitoring_zabbix_psk_store` | string | `{{ role_path }}/../../.zabbix-psk` | PSK-Store-Verzeichnis auf dem Controller |
|
||||
| `monitoring_zabbix_psk_store_mode` | string | `0700` | Berechtigung des PSK-Stores |
|
||||
|
||||
### Zabbix Proxy (optional)
|
||||
@@ -109,7 +111,7 @@ Tag `monitoring`):
|
||||
|
||||
| Variable | Typ | Default | Beschreibung |
|
||||
|---------------------------------------------|--------|--------------------------------------|---------------------------------------------------------|
|
||||
| `monitoring_zabbix_api_url` | string | `https://zabbix/api_jsonrpc.php` | API-URL |
|
||||
| `monitoring_zabbix_api_url` | string | `https://zabbix/api_jsonrpc.php` | API-URL (wird via `urlsplit` in Host, Port, Pfad zerlegt) |
|
||||
| `monitoring_zabbix_api_user` | string | `Admin` | API-Benutzer |
|
||||
| `monitoring_zabbix_api_password` | string | (Vault) | API-Passwort – MUSS in `vault.yml` gesetzt werden |
|
||||
| `monitoring_zabbix_api_validate_certs` | bool | `true` | TLS-Zertifikate prüfen |
|
||||
@@ -151,7 +153,7 @@ Passive-Servers mit Proxy-Adresse, setzt `ServerActive` auf Proxy).
|
||||
`monitoring` – alle Subtasks sind mit diesem Tag versehen:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml playbooks/monitoring.yml -t monitoring
|
||||
ansible-playbook -i inventory/cloudlorean.yml playbooks/monitoring.yml -t monitoring
|
||||
```
|
||||
|
||||
## Abhängigkeiten
|
||||
@@ -163,14 +165,21 @@ ansible-playbook -i inventory/dmc12.yml playbooks/monitoring.yml -t monitoring
|
||||
## Hinweise
|
||||
|
||||
- **PSK-Store**: Pro Host wird eine PSK unter
|
||||
`<playbook_dir>/../.zabbix-psk/<hostname>.psk` (git-ignored) gespeichert.
|
||||
`<Repository-Root>/.zabbix-psk/<hostname>.psk` (git-ignored) gespeichert.
|
||||
Bei Host-Umbenennung PSK migrieren oder neu generieren – sonst stimmt die
|
||||
Zabbix-Registrierung nicht.
|
||||
- **PSK-Identity**: Die Agent-Konfiguration und die Zabbix-Hostkonfiguration
|
||||
verwenden dieselbe Identity. Wenn `monitoring_zabbix_host_name` überschrieben
|
||||
wird, wird die Identity standardmäßig automatisch daran angepasst.
|
||||
- **API-Passwort** MUSS in `vault.yml` als `monitoring_zabbix_api_password`
|
||||
gesetzt sein; die Validate-Tasks brechen sonst ab.
|
||||
- **Docker-Plugin** wird nur konfiguriert, wenn der Socket existiert – sonst
|
||||
wird eine eventuell vorhandene Plugin-Config entfernt (Idempotenz).
|
||||
- Die Registrierung wird **delegiert an localhost** ausgeführt, da der
|
||||
Controller den API-Zugang besitzt.
|
||||
- Proxy- und Server-Modus schließen sich gegenseitig aus (zwei Tasks mit
|
||||
entgegengesetzten `when`-Bedingungen).
|
||||
- Die Registrierung nutzt die `httpapi`-Connection
|
||||
(`ansible_network_os: community.zabbix.zabbix`, `ansible_connection: httpapi`)
|
||||
und läuft direkt vom Controller aus – kein `delegate_to` nötig.
|
||||
Die API-URL wird per `urlsplit` in Host, Port, SSL und Pfad zerlegt;
|
||||
User/Passwort kommen als `ansible_user`/`ansible_password` in die
|
||||
Task-Vars.
|
||||
- Proxy- und Server-Modus werden über `monitored_by` gesteuert
|
||||
(`proxy` bei gesetztem `monitoring_zabbix_proxy`, sonst `zabbix_server`).
|
||||
|
||||
@@ -17,11 +17,11 @@ monitoring_zabbix_docker_endpoint: "unix://{{ monitoring_zabbix_docker_socket_pa
|
||||
# --- TLS / PSK ----------------------------------------------------------------
|
||||
monitoring_zabbix_tls_connect: psk # outgoing connections from agent: psk
|
||||
monitoring_zabbix_tls_accept: psk # incoming connections to agent: psk
|
||||
monitoring_zabbix_psk_identity: "{{ inventory_hostname }}"
|
||||
monitoring_zabbix_psk_identity: "{{ monitoring_zabbix_host_name }}"
|
||||
monitoring_zabbix_psk_file: /etc/zabbix/zabbix_agent2.psk
|
||||
monitoring_zabbix_psk_bits: 256 # 32 bytes -> 64 hex chars
|
||||
# Directory on the Ansible controller used to persist per-host PSKs across runs.
|
||||
monitoring_zabbix_psk_store: "{{ playbook_dir }}/../.zabbix-psk"
|
||||
monitoring_zabbix_psk_store: "{{ role_path }}/../../.zabbix-psk"
|
||||
monitoring_zabbix_psk_store_mode: "0700"
|
||||
|
||||
# --- Zabbix Proxy (optional) --------------------------------------------------
|
||||
@@ -45,4 +45,4 @@ monitoring_zabbix_host_inventory_mode: manual
|
||||
# Templates linked to every host
|
||||
monitoring_zabbix_templates: ["Linux by Zabbix agent", "Zabbix agent2"]
|
||||
# Templates added when a Docker socket is present on the host
|
||||
monitoring_zabbix_docker_templates: ["Docker by Zabbix agent2"]
|
||||
monitoring_zabbix_docker_templates: ["Docker by Zabbix agent2"]
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
become: false
|
||||
run_once: false
|
||||
|
||||
- name: Show PSK store path
|
||||
ansible.builtin.debug:
|
||||
msg: "Persisting PSKs on the controller in {{ monitoring_zabbix_psk_store }}"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
changed_when: false
|
||||
|
||||
- name: Check whether PSK already exists on controller
|
||||
ansible.builtin.stat:
|
||||
path: "{{ monitoring_zabbix_psk_store }}/{{ inventory_hostname }}.psk"
|
||||
@@ -37,6 +44,17 @@
|
||||
monitoring_zabbix_psk_store ~ '/' ~ inventory_hostname ~ '.psk')
|
||||
| trim }}
|
||||
|
||||
- name: Validate PSK format
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- monitoring_zabbix_psk_value is match('^[0-9a-fA-F]+$')
|
||||
- monitoring_zabbix_psk_value | length == (monitoring_zabbix_psk_bits / 4) | int
|
||||
fail_msg: >-
|
||||
The PSK must contain exactly {{ (monitoring_zabbix_psk_bits / 4) | int }}
|
||||
hexadecimal characters.
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
- name: Ensure Zabbix agent runtime directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ monitoring_zabbix_psk_file | dirname | default('/etc/zabbix') }}"
|
||||
@@ -52,4 +70,4 @@
|
||||
owner: "{{ monitoring_zabbix_agent_user }}"
|
||||
group: "{{ monitoring_zabbix_agent_user }}"
|
||||
mode: '0600'
|
||||
notify: Restart Zabbix Agent
|
||||
notify: Restart Zabbix Agent
|
||||
|
||||
@@ -24,52 +24,36 @@
|
||||
dns: "{{ inventory_hostname }}"
|
||||
port: "{{ monitoring_zabbix_host_interface_port }}"
|
||||
|
||||
- name: Register or update host in Zabbix (monitored by proxy)
|
||||
- name: Register or update host in Zabbix
|
||||
community.zabbix.zabbix_host:
|
||||
server_url: "{{ monitoring_zabbix_api_url }}"
|
||||
login_user: "{{ monitoring_zabbix_api_user }}"
|
||||
login_password: "{{ monitoring_zabbix_api_password }}"
|
||||
validate_certs: "{{ monitoring_zabbix_api_validate_certs }}"
|
||||
host_name: "{{ monitoring_zabbix_host_name }}"
|
||||
visible_name: "{{ monitoring_zabbix_host_name }}"
|
||||
host_groups: "{{ monitoring_zabbix_host_groups }}"
|
||||
link_templates: "{{ monitoring_zabbix_link_templates }}"
|
||||
interfaces: "{{ monitoring_zabbix_interfaces }}"
|
||||
inventory_mode: "{{ monitoring_zabbix_host_inventory_mode }}"
|
||||
monitored_by: proxy
|
||||
proxy: "{{ monitoring_zabbix_proxy }}"
|
||||
monitored_by: "{{ 'proxy' if monitoring_zabbix_proxy | length > 0 else 'zabbix_server' }}"
|
||||
proxy: "{{ monitoring_zabbix_proxy | default(omit) }}"
|
||||
tls_connect: 2
|
||||
tls_accept: 2
|
||||
tls_psk_identity: "{{ monitoring_zabbix_psk_identity }}"
|
||||
tls_psk: "{{ monitoring_zabbix_psk_value }}"
|
||||
status: enabled
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
vars:
|
||||
ansible_network_os: community.zabbix.zabbix
|
||||
ansible_connection: httpapi
|
||||
ansible_host: "{{ (monitoring_zabbix_api_url | urlsplit).hostname }}"
|
||||
ansible_httpapi_port: "{{ (monitoring_zabbix_api_url | urlsplit).port | default(443, true) }}"
|
||||
ansible_httpapi_use_ssl: "{{ (monitoring_zabbix_api_url | urlsplit).scheme == 'https' }}"
|
||||
ansible_httpapi_validate_certs: "{{ monitoring_zabbix_api_validate_certs }}"
|
||||
ansible_zabbix_url_path: >-
|
||||
{{
|
||||
(monitoring_zabbix_api_url | urlsplit).path
|
||||
| regex_replace('^/', '')
|
||||
| regex_replace('/?api_jsonrpc\.php$', '')
|
||||
}}
|
||||
ansible_user: "{{ monitoring_zabbix_api_user }}"
|
||||
ansible_password: "{{ monitoring_zabbix_api_password }}"
|
||||
become: false
|
||||
when:
|
||||
- monitoring_zabbix_register_host | bool
|
||||
- monitoring_zabbix_proxy | length > 0
|
||||
|
||||
- name: Register or update host in Zabbix (monitored by server)
|
||||
community.zabbix.zabbix_host:
|
||||
server_url: "{{ monitoring_zabbix_api_url }}"
|
||||
login_user: "{{ monitoring_zabbix_api_user }}"
|
||||
login_password: "{{ monitoring_zabbix_api_password }}"
|
||||
validate_certs: "{{ monitoring_zabbix_api_validate_certs }}"
|
||||
host_name: "{{ monitoring_zabbix_host_name }}"
|
||||
visible_name: "{{ monitoring_zabbix_host_name }}"
|
||||
host_groups: "{{ monitoring_zabbix_host_groups }}"
|
||||
link_templates: "{{ monitoring_zabbix_link_templates }}"
|
||||
interfaces: "{{ monitoring_zabbix_interfaces }}"
|
||||
inventory_mode: "{{ monitoring_zabbix_host_inventory_mode }}"
|
||||
tls_connect: 2
|
||||
tls_accept: 2
|
||||
tls_psk_identity: "{{ monitoring_zabbix_psk_identity }}"
|
||||
tls_psk: "{{ monitoring_zabbix_psk_value }}"
|
||||
status: enabled
|
||||
state: present
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
when:
|
||||
- monitoring_zabbix_register_host | bool
|
||||
- monitoring_zabbix_proxy | length == 0
|
||||
when: monitoring_zabbix_register_host | bool
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
Aktualisiert alle installierten Pakete auf Debian-Hosts, optional mit
|
||||
Spiegel-Wechsel (Mirror-Switch) und Codename-Anpassung. Die Rolle führt bei
|
||||
Bedarf einen Reboot durch (nur bei neuem Kernel, nicht in LXC-Containern)
|
||||
und schreibt ein detailliertes Update-Log auf den Ansible-Controller.
|
||||
Bedarf einen Reboot durch (nur bei neuem Kernel, nicht in LXC-Containern oder
|
||||
standardmäßig auf Proxmox-Hypervisoren) und schreibt ein detailliertes
|
||||
Update-Log auf den Ansible-Controller.
|
||||
|
||||
> Siehe auch das Playbook `playbooks/os-updates-deb.yml` (in dem direkt im
|
||||
> Anschluss die `healthcheck`-Rolle läuft) sowie die
|
||||
@@ -26,7 +27,7 @@ und schreibt ein detailliertes Update-Log auf den Ansible-Controller.
|
||||
```
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/dmc12.yml playbooks/os-updates-deb.yml
|
||||
ansible-playbook -i inventory/cloudlorean.yml playbooks/os-updates-deb.yml
|
||||
```
|
||||
|
||||
## Funktionsweise
|
||||
@@ -51,9 +52,11 @@ ansible-playbook -i inventory/dmc12.yml playbooks/os-updates-deb.yml
|
||||
Pakete, zeichnet Start-Zeitpunkt auf.
|
||||
- `apt upgrade: full` – vollständiges Upgrade aller Pakete. Benachrichtigt
|
||||
Handler `apt cleanup` und `apt autoremove`.
|
||||
- `reboot.yml` – entscheidet über Reboot-Vergleich von laufendem und
|
||||
installiertem Kernel, rebootet asynchron, wartet auf Wiederkehr,
|
||||
erfasst Downtime. Wird in LXC-Containern übersprungen.
|
||||
- `reboot.yml` – entscheidet über Reboot-Vergleich von laufendem und
|
||||
installiertem Kernel, rebootet asynchron, wartet auf Wiederkehr,
|
||||
erfasst Downtime. Auf Hosts in der Inventory-Gruppe `proxmox` wird der
|
||||
notwendige Reboot standardmäßig nur gemeldet und nicht ausgeführt.
|
||||
Wird in LXC-Containern übersprungen.
|
||||
- `logging_postflight.yml` – berechnet Dauer, schreibt Log-Eintrag mit
|
||||
allen Fakten in `os_update_log_file` (delegiert an localhost).
|
||||
|
||||
@@ -62,6 +65,12 @@ ansible-playbook -i inventory/dmc12.yml playbooks/os-updates-deb.yml
|
||||
- Läuft ein älterer Kernel als installiert, gilt `reboot_required: true`.
|
||||
- Der Reboot erfolgt mit `async: 1`, `poll: 0`, gefolgt von
|
||||
`wait_for_connection` (Delay 10s, Timeout 600s).
|
||||
- Auf Proxmox-Hypervisoren (`'proxmox' in group_names`) wird bei einem
|
||||
notwendigen Reboot eine Meldung ausgegeben und `reboot_deferred: true` im
|
||||
Log gesetzt. So kann der Hypervisor kontrolliert außerhalb dieses Laufs
|
||||
neu gestartet werden.
|
||||
- Mit `os_update_reboot_on_proxmox: true` kann der automatische Reboot für
|
||||
einen Proxmox-Host explizit aktiviert werden.
|
||||
- In LXC-Containern (`virtualization_type == "lxc"`) wird der gesamte
|
||||
Reboot-Block übersprungen.
|
||||
|
||||
@@ -71,6 +80,7 @@ ansible-playbook -i inventory/dmc12.yml playbooks/os-updates-deb.yml
|
||||
|-----------------------------|--------|----------------------------------------------------------|-------------------------------------------------------------|
|
||||
| `os_update_auto_upgrade` | bool | `true` | (Steuer-Vorbereitung) Auto-Upgrade erlauben |
|
||||
| `os_also_update_mirror` | bool | `false` | Spiegel-Wechsel und Codename-Rewrite durchführen |
|
||||
| `os_update_reboot_on_proxmox` | bool | `false` | Reboot auf Hosts der Inventory-Gruppe `proxmox` zulassen; standardmäßig wird nur gemeldet |
|
||||
| `os_update_logging_enabled`| bool | `true` | Update-Logging aktivieren |
|
||||
| `os_update_log_dir` | string | `/ansible/logs` | Basis-Verzeichnis für Logs |
|
||||
| `os_update_log_inventory` | string | `{{ inventory_file \| basename \| splitext \| first }}` | Inventory-Name (abgeleitet) |
|
||||
@@ -125,4 +135,4 @@ Die Rolle vergibt keine eigenen Tags.
|
||||
- **LXC**: In Containern wird der Reboot-Block komplett übersprungen
|
||||
(`virtualization_type != "lxc"`).
|
||||
- **Idempotenz**: `apt upgrade: full` meldet `changed`, wenn Pakete
|
||||
aktualisiert wurden; ohne anstehende Updates ist der Lauf "ok".
|
||||
aktualisiert wurden; ohne anstehende Updates ist der Lauf "ok".
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Standardwerte, die überschrieben werden können
|
||||
os_update_auto_upgrade: true
|
||||
os_also_update_mirror: false
|
||||
os_update_reboot_on_proxmox: false
|
||||
|
||||
# Logging of OS update runs (preflight package count/list, updated packages, duration)
|
||||
os_update_logging_enabled: true
|
||||
@@ -16,4 +17,4 @@ os_update_debian_codenames:
|
||||
# Only these suites are considered Debian codenames and will be rewritten in sources.list.d
|
||||
- trixie
|
||||
- bookworm
|
||||
- bullseye
|
||||
- bullseye
|
||||
|
||||
@@ -38,9 +38,10 @@
|
||||
reboot_required: {{ os_update_reboot_required }}
|
||||
reboot_reason: {{ os_update_reboot_reason }}
|
||||
reboot_triggered: {{ os_update_reboot_triggered }}
|
||||
reboot_deferred: {{ os_update_reboot_deferred }}
|
||||
reboot_started: {{ os_update_reboot_start_iso }}
|
||||
reboot_downtime_seconds: {{ os_update_reboot_downtime_seconds }}
|
||||
kernel_before: {{ os_update_running_kernel.stdout | default('n/a') }}
|
||||
kernel_after: {{ os_update_running_kernel_after }}
|
||||
delegate_to: localhost
|
||||
when: os_update_logging_enabled | bool
|
||||
when: os_update_logging_enabled | bool
|
||||
|
||||
@@ -34,10 +34,27 @@
|
||||
- name: Default reboot timing facts
|
||||
set_fact:
|
||||
os_update_reboot_triggered: false
|
||||
os_update_reboot_deferred: false
|
||||
os_update_reboot_start_iso: "n/a"
|
||||
os_update_reboot_downtime_seconds: 0
|
||||
os_update_running_kernel_after: "{{ os_update_running_kernel.stdout | default('n/a') }}"
|
||||
|
||||
- name: Notify when reboot is deferred on Proxmox
|
||||
ansible.builtin.debug:
|
||||
msg: "Reboot required but deferred on Proxmox host {{ ansible_facts['hostname'] }}: {{ os_update_reboot_reason }}"
|
||||
when:
|
||||
- os_update_reboot_required | bool
|
||||
- "'proxmox' in group_names"
|
||||
- not os_update_reboot_on_proxmox | bool
|
||||
|
||||
- name: Record deferred reboot on Proxmox
|
||||
ansible.builtin.set_fact:
|
||||
os_update_reboot_deferred: true
|
||||
when:
|
||||
- os_update_reboot_required | bool
|
||||
- "'proxmox' in group_names"
|
||||
- not os_update_reboot_on_proxmox | bool
|
||||
|
||||
- block:
|
||||
- name: Reboot - Record start time
|
||||
command: date -Iseconds
|
||||
@@ -80,4 +97,6 @@
|
||||
os_update_reboot_triggered: true
|
||||
os_update_reboot_start_iso: "{{ os_update_reboot_start_iso_raw.stdout }}"
|
||||
os_update_running_kernel_after: "{{ os_update_running_kernel_after_raw.stdout }}"
|
||||
when: os_update_reboot_required | bool
|
||||
when:
|
||||
- os_update_reboot_required | bool
|
||||
- "'proxmox' not in group_names or os_update_reboot_on_proxmox | bool"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
apt:
|
||||
upgrade: full
|
||||
update_cache: yes
|
||||
install_recommends: true
|
||||
register: os_update_upgrade_result
|
||||
notify:
|
||||
- apt cleanup
|
||||
|
||||
Reference in New Issue
Block a user