feat: add present/absent branching for Auftragskatalog roles
Adds a tuxflotte_state variable, threaded from a new tuxflotte_auftrag_states dict in site.yml (role name -> present/absent, populated by the agent from the checkin response's "auftraege" list, see ADR-0010) down into each role via include_role vars. Roles not present in that dict default to "present" via .get(), so today's purely workspace-composed, additive-only behavior is unchanged. Retrofits all three existing placeholder roles with the present/absent branch as the reference implementation of the convention, and documents it in the README for future catalog-eligible roles. This is what makes deselecting an Auftrag actually revert something instead of just stopping future re-application. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
ddcdeccab4
commit
28e6c067a1
28
README.md
28
README.md
@ -14,8 +14,32 @@ ansible-pull -U <repo-url> --tags <rolle1>,<rolle2>,... -i localhost, site.yml
|
|||||||
|
|
||||||
Alle Rollen sind Platzhalter — sie hinterlegen nur eine Marker-Datei unter `/run/tuxflotte/agent/applied/<rolle>.marker`, um die End-to-End-Pipeline (Server → Agent → ansible-pull → Rolle) nachzuweisen. Echte Rolleninhalte folgen später.
|
Alle Rollen sind Platzhalter — sie hinterlegen nur eine Marker-Datei unter `/run/tuxflotte/agent/applied/<rolle>.marker`, um die End-to-End-Pipeline (Server → Agent → ansible-pull → Rolle) nachzuweisen. Echte Rolleninhalte folgen später.
|
||||||
|
|
||||||
|
## present/absent (Auftragskatalog, ADR-0010)
|
||||||
|
|
||||||
|
Merkmale, die für die geräteweise Ad-hoc-Zuweisung über den Auftragskatalog freigegeben sind (`merkmale.im_auftragskatalog = true`), können nicht nur zugewiesen, sondern auch wieder abgewählt werden — und das muss real etwas zurückbauen, nicht nur zukünftige Anwendung verhindern.
|
||||||
|
|
||||||
|
Dafür reicht der Agent bei jedem `ansible-pull`-Lauf eine Variable `tuxflotte_auftrag_states` durch (Rollenname → `"present"`/`"absent"`, aus der Check-in-Antwort `auftraege`), die `site.yml` pro Rolle als `tuxflotte_state` an die jeweilige Rolle weiterreicht. Rollen, die dort nicht auftauchen (zum Beispiel weil sie nur workspace-komponiert sind, nicht katalogfähig), laufen unverändert additiv über `--tags`, ohne `absent`-Zustand — siehe `tuxflotte_auftrag_states.get(<rolle>, 'present')` in `site.yml`.
|
||||||
|
|
||||||
|
Jede Rolle, die katalogfähig werden soll, muss deshalb ihre Tasks auf `tuxflotte_state` verzweigen:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: <Merkmal anwenden>
|
||||||
|
...
|
||||||
|
when: tuxflotte_state == "present"
|
||||||
|
|
||||||
|
- name: <Merkmal zurückbauen>
|
||||||
|
...
|
||||||
|
when: tuxflotte_state == "absent"
|
||||||
|
```
|
||||||
|
|
||||||
|
`tuxflotte_state` hat in `roles/<name>/defaults/main.yml` den Default `present`, damit die Rolle auch bei direkter Verwendung ohne die `site.yml`-Verdrahtung nicht auf eine undefinierte Variable trifft.
|
||||||
|
|
||||||
|
Rollen, die nie katalogfähig werden (rein workspace-komponierte Merkmale), brauchen keinen `absent`-Zweig — das ist bewusst kein Zwang für alle Rollen, nur für die, die tatsächlich im Auftragskatalog landen.
|
||||||
|
|
||||||
## Neue Rolle hinzufügen
|
## Neue Rolle hinzufügen
|
||||||
|
|
||||||
1. `roles/<name>/tasks/main.yml` anlegen
|
1. `roles/<name>/tasks/main.yml` anlegen
|
||||||
2. Eintrag in `site.yml` mit `tags: <name>` ergänzen
|
2. `roles/<name>/defaults/main.yml` mit `tuxflotte_state: present` anlegen
|
||||||
3. Entsprechenden `ansible_role`-Wert in der `blueprints`-Tabelle referenzieren
|
3. Eintrag in `site.yml` mit `tags: <name>` und `vars: tuxflotte_state: "{{ tuxflotte_auftrag_states.get('<name>', 'present') }}"` ergänzen
|
||||||
|
4. Entsprechenden `ansible_role`-Wert in der `blueprints`-Tabelle referenzieren
|
||||||
|
5. Nur falls die Rolle katalogfähig werden soll (`im_auftragskatalog = true`): Tasks wie oben auf `tuxflotte_state` verzweigen, sonst reicht der additive Pfad ohne `when`
|
||||||
|
|||||||
1
roles/brave-fedora/defaults/main.yml
Normal file
1
roles/brave-fedora/defaults/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
tuxflotte_state: present
|
||||||
@ -9,3 +9,10 @@
|
|||||||
dest: /run/tuxflotte/agent/applied/brave-fedora.marker
|
dest: /run/tuxflotte/agent/applied/brave-fedora.marker
|
||||||
content: "{{ ansible_date_time.iso8601 }}\n"
|
content: "{{ ansible_date_time.iso8601 }}\n"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
when: tuxflotte_state == "present"
|
||||||
|
|
||||||
|
- name: Remove brave-fedora marker (Auftrag abgewählt)
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /run/tuxflotte/agent/applied/brave-fedora.marker
|
||||||
|
state: absent
|
||||||
|
when: tuxflotte_state == "absent"
|
||||||
|
|||||||
1
roles/guest-session/defaults/main.yml
Normal file
1
roles/guest-session/defaults/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
tuxflotte_state: present
|
||||||
@ -9,3 +9,10 @@
|
|||||||
dest: /run/tuxflotte/agent/applied/guest-session.marker
|
dest: /run/tuxflotte/agent/applied/guest-session.marker
|
||||||
content: "{{ ansible_date_time.iso8601 }}\n"
|
content: "{{ ansible_date_time.iso8601 }}\n"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
when: tuxflotte_state == "present"
|
||||||
|
|
||||||
|
- name: Remove guest-session marker (Auftrag abgewählt)
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /run/tuxflotte/agent/applied/guest-session.marker
|
||||||
|
state: absent
|
||||||
|
when: tuxflotte_state == "absent"
|
||||||
|
|||||||
1
roles/onlyoffice-fedora/defaults/main.yml
Normal file
1
roles/onlyoffice-fedora/defaults/main.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
tuxflotte_state: present
|
||||||
@ -9,3 +9,10 @@
|
|||||||
dest: /run/tuxflotte/agent/applied/onlyoffice-fedora.marker
|
dest: /run/tuxflotte/agent/applied/onlyoffice-fedora.marker
|
||||||
content: "{{ ansible_date_time.iso8601 }}\n"
|
content: "{{ ansible_date_time.iso8601 }}\n"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
when: tuxflotte_state == "present"
|
||||||
|
|
||||||
|
- name: Remove onlyoffice-fedora marker (Auftrag abgewählt)
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /run/tuxflotte/agent/applied/onlyoffice-fedora.marker
|
||||||
|
state: absent
|
||||||
|
when: tuxflotte_state == "absent"
|
||||||
|
|||||||
12
site.yml
12
site.yml
@ -1,21 +1,33 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
become: true
|
become: true
|
||||||
|
vars:
|
||||||
|
# Vom Agenten per --extra-vars gesetzt (siehe ADR-0010, provisioning-server
|
||||||
|
# Check-in-Response "auftraege"): Rollenname -> "present"/"absent". Rollen,
|
||||||
|
# die hier nicht auftauchen (z.B. weil sie nur workspace-komponiert sind),
|
||||||
|
# bleiben beim Default "present" - unverändert additives Verhalten.
|
||||||
|
tuxflotte_auftrag_states: {}
|
||||||
tasks:
|
tasks:
|
||||||
- include_role:
|
- include_role:
|
||||||
name: guest-session
|
name: guest-session
|
||||||
apply:
|
apply:
|
||||||
tags: guest-session
|
tags: guest-session
|
||||||
|
vars:
|
||||||
|
tuxflotte_state: "{{ tuxflotte_auftrag_states.get('guest-session', 'present') }}"
|
||||||
tags: guest-session
|
tags: guest-session
|
||||||
|
|
||||||
- include_role:
|
- include_role:
|
||||||
name: brave-fedora
|
name: brave-fedora
|
||||||
apply:
|
apply:
|
||||||
tags: brave-fedora
|
tags: brave-fedora
|
||||||
|
vars:
|
||||||
|
tuxflotte_state: "{{ tuxflotte_auftrag_states.get('brave-fedora', 'present') }}"
|
||||||
tags: brave-fedora
|
tags: brave-fedora
|
||||||
|
|
||||||
- include_role:
|
- include_role:
|
||||||
name: onlyoffice-fedora
|
name: onlyoffice-fedora
|
||||||
apply:
|
apply:
|
||||||
tags: onlyoffice-fedora
|
tags: onlyoffice-fedora
|
||||||
|
vars:
|
||||||
|
tuxflotte_state: "{{ tuxflotte_auftrag_states.get('onlyoffice-fedora', 'present') }}"
|
||||||
tags: onlyoffice-fedora
|
tags: onlyoffice-fedora
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user