reimage-check erkennt die Platte DEZNTRSICHERUNG mit neuerem Image und bootet in den GRUB-Eintrag Schul-Neuinstallation (Clonezilla toram). schul-reimage.sh: Mini-Menue (AUFSPIELEN auto nach 20 s / IMAGE ERSTELLEN / Abbrechen), ocs-sr im Batch-Modus ohne Nachpruefung (E-004), Hostname bleibt erhalten, Admin-Key nur auf laptop03 (E-005). local.yml haelt alles per Pull aktuell. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
133 lines
3.7 KiB
YAML
133 lines
3.7 KiB
YAML
---
|
|
# Wird per ansible-pull auf jedem Laptop lokal ausgefuehrt (via schul-pull.sh).
|
|
# Aenderungen hier verteilen sich beim naechsten Timer-Lauf auf alle Laptops.
|
|
- name: Schul-Laptop konfigurieren
|
|
hosts: localhost
|
|
connection: local
|
|
become: true
|
|
|
|
tasks:
|
|
- name: APT-Cache aktualisieren
|
|
apt:
|
|
update_cache: yes
|
|
cache_valid_time: 3600
|
|
|
|
- name: System-Updates installieren (safe upgrade)
|
|
apt:
|
|
upgrade: safe
|
|
|
|
- name: Standard-Software installieren
|
|
apt:
|
|
name: "{{ schul_pakete }}"
|
|
state: present
|
|
|
|
# --- Selbstverwaltung: haelt die Pull-Mechanik auf allen Laptops aktuell ---
|
|
|
|
- name: Pull-Script installieren
|
|
copy:
|
|
src: files/schul-pull.sh
|
|
dest: /usr/local/bin/schul-pull.sh
|
|
mode: "0755"
|
|
|
|
- name: systemd-Units fuer ansible-pull installieren
|
|
copy:
|
|
src: "files/{{ item }}"
|
|
dest: "/etc/systemd/system/{{ item }}"
|
|
mode: "0644"
|
|
loop:
|
|
- ansible-pull.service
|
|
- ansible-pull.timer
|
|
register: units
|
|
|
|
- name: systemd neu laden, falls Units geaendert
|
|
systemd:
|
|
daemon_reload: yes
|
|
when: units.changed
|
|
|
|
- name: ansible-pull.timer aktivieren
|
|
systemd:
|
|
name: ansible-pull.timer
|
|
enabled: yes
|
|
state: started
|
|
|
|
# --- Jahres-Reimage: Boot-Check + GRUB-Eintrag aktuell halten ---
|
|
|
|
- name: reimage-check-Script installieren
|
|
copy:
|
|
src: files/reimage-check.sh
|
|
dest: /usr/local/bin/reimage-check.sh
|
|
mode: "0755"
|
|
|
|
- name: reimage-check.service installieren
|
|
copy:
|
|
src: files/reimage-check.service
|
|
dest: /etc/systemd/system/reimage-check.service
|
|
mode: "0644"
|
|
register: reimage_unit
|
|
|
|
- name: systemd neu laden, falls reimage-Unit geaendert
|
|
systemd:
|
|
daemon_reload: yes
|
|
when: reimage_unit.changed
|
|
|
|
- name: reimage-check aktivieren (alle ausser Master laptop03)
|
|
systemd:
|
|
name: reimage-check.service
|
|
enabled: "{{ 'no' if ansible_hostname == 'laptop03' else 'yes' }}"
|
|
|
|
- name: GRUB auf gespeicherten Default umstellen (fuer grub-reboot)
|
|
lineinfile:
|
|
path: /etc/default/grub
|
|
regexp: '^GRUB_DEFAULT='
|
|
line: 'GRUB_DEFAULT=saved'
|
|
register: grub_default
|
|
|
|
- name: update-grub ausfuehren, falls GRUB-Konfig geaendert
|
|
command: update-grub
|
|
when: grub_default.changed
|
|
|
|
- name: Normalen Boot als gespeicherten Default setzen
|
|
command: grub-set-default 0
|
|
args:
|
|
creates: /boot/grub/grubenv
|
|
|
|
- name: GRUB-Eintrag Schul-Neuinstallation installieren
|
|
copy:
|
|
src: files/clonezilla/grub-custom.cfg
|
|
dest: /boot/grub/custom.cfg
|
|
mode: "0644"
|
|
|
|
- name: Verzeichnis /boot/clonezilla anlegen
|
|
file:
|
|
path: /boot/clonezilla
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Reimage-Skript nach /boot/clonezilla verteilen
|
|
copy:
|
|
src: files/clonezilla/schul-reimage.sh
|
|
dest: /boot/clonezilla/schul-reimage.sh
|
|
mode: "0755"
|
|
|
|
- name: Pruefen ob Clonezilla-Live-Dateien vorhanden sind
|
|
stat:
|
|
path: /boot/clonezilla/filesystem.squashfs
|
|
register: clonezilla_live
|
|
|
|
- name: Hinweis falls Clonezilla-Live-Dateien fehlen
|
|
debug:
|
|
msg: "HINWEIS: /boot/clonezilla ohne Live-Dateien (vmlinuz, initrd.img, filesystem.squashfs) — Reimage ohne Stick nicht moeglich."
|
|
when: not clonezilla_live.stat.exists
|
|
|
|
# --- Status melden ---
|
|
|
|
- name: Pruefen ob ein Neustart noetig ist
|
|
stat:
|
|
path: /var/run/reboot-required
|
|
register: reboot_required
|
|
|
|
- name: Neustart-Hinweis ins Log schreiben
|
|
debug:
|
|
msg: "ACHTUNG: Neustart erforderlich (wird nicht automatisch ausgefuehrt)."
|
|
when: reboot_required.stat.exists
|