mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
- Rename host mount namespace from /prole/d00x to /synology/d00x - Make LUN ownership explicit per host in inventory (myrddin=d001; merlin=d002,d004; pi=d003) - Add safe migration cleanup for legacy /prole/d00x mounts and stale /etc/fstab entries - Update k3s/ArgoCD/OpenTofu manifests and PV node affinities to match new mount paths - Improve iSCSI role check-mode behavior and add quiesce/detach flow in ansible.sh
69 lines
2.1 KiB
YAML
69 lines
2.1 KiB
YAML
---
|
|
- name: Require iscsi_portal when logging out absent targets
|
|
ansible.builtin.assert:
|
|
that:
|
|
- iscsi_portal is defined
|
|
- (iscsi_portal | string | length) > 0
|
|
fail_msg: "iscsi_absent_targets is set but iscsi_portal is missing/empty."
|
|
when: (iscsi_absent_targets | default([]) | length) > 0
|
|
|
|
- name: Unmount absent iSCSI mountpoints
|
|
ansible.builtin.mount:
|
|
path: "{{ item.path | default(item) }}"
|
|
state: unmounted
|
|
loop: "{{ iscsi_absent_mounts | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item.path | default(item) }}"
|
|
tags:
|
|
- iscsi_cleanup
|
|
|
|
- name: Remove absent iSCSI fstab entries
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/fstab
|
|
state: absent
|
|
regexp: "^\\s*\\S+\\s+{{ (item.path | default(item)) | regex_escape }}\\s+"
|
|
loop: "{{ iscsi_absent_mounts | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item.path | default(item) }}"
|
|
tags:
|
|
- iscsi_cleanup
|
|
|
|
- name: Check for active sessions for absent targets
|
|
ansible.builtin.shell: >-
|
|
iscsiadm -m session 2>/dev/null | grep -Fq -- {{ item | quote }}
|
|
register: _iscsi_absent_target_session_checks
|
|
changed_when: false
|
|
failed_when: false
|
|
loop: "{{ iscsi_absent_targets | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when: (iscsi_absent_targets | default([]) | length) > 0
|
|
tags:
|
|
- iscsi_cleanup
|
|
|
|
- name: Logout absent iSCSI targets (active sessions only)
|
|
ansible.builtin.command: >-
|
|
iscsiadm -m node -T {{ item.item }} -p {{ iscsi_portal }} --logout
|
|
register: _iscsi_absent_target_logout
|
|
changed_when: false
|
|
failed_when: false
|
|
loop: "{{ _iscsi_absent_target_session_checks.results | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item.item }}"
|
|
when:
|
|
- (iscsi_absent_targets | default([]) | length) > 0
|
|
- item.rc == 0
|
|
tags:
|
|
- iscsi_cleanup
|
|
|
|
- name: Delete node records for absent iSCSI targets (best-effort)
|
|
ansible.builtin.command: >-
|
|
iscsiadm -m node -o delete -T {{ item }} -p {{ iscsi_portal }}
|
|
changed_when: false
|
|
failed_when: false
|
|
loop: "{{ iscsi_absent_targets | default([]) }}"
|
|
loop_control:
|
|
label: "{{ item }}"
|
|
when: (iscsi_absent_targets | default([]) | length) > 0
|
|
tags:
|
|
- iscsi_cleanup |