prole/infrastructure/roles/iscsi/tasks/mount.yml
chrisfu f051d1d42a iscsi/installer: provision merlin d004; fix etc script runtime
- Add merlin iSCSI config for PROLE-DATA-4 mounted at /prole/d004 (xfs, _netdev,noatime)

- Refine iscsi role login/mount flow (device resolution, mkfs-if-missing, UUID fstab, tags)

- Ensure installer run_script stages lib/shell into PROLE_HOME so etc scripts can source common libs; add regression test

- Add init scripts for Forgejo/GitLab; ignore generated conf/prole.cfg

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-16 21:30:52 -07:00

61 lines
1.9 KiB
YAML

---
- name: Unmount stale iSCSI mounts
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: Guardrail - iSCSI must not manage /var/lib/rancher
ansible.builtin.assert:
that:
- >-
(iscsi_targets | default([])
| map(attribute='mounts') | list | flatten
| selectattr('path', 'equalto', '/var/lib/rancher')
| list | length) == 0
fail_msg: >-
Inventory attempts to mount `/var/lib/rancher` via iSCSI. K3s state storage is
intended to be local host storage (e.g. USB3 SSD on myrddin). Remove
`/var/lib/rancher` from `iscsi_targets[*].mounts` (or set
`iscsi_allow_rancher_mount: true` if you are intentionally overriding this).
when: not (iscsi_allow_rancher_mount | default(false) | bool)
- name: Remove stale 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: Mount filesystems for iSCSI targets
ansible.builtin.include_tasks: iscsi_target_mounts.yml
loop: "{{ iscsi_targets | default([]) }}"
loop_control:
loop_var: t
label: "{{ t.iqn | default('<unknown-iqn>') }}"
tags:
- iscsi
- iscsi_mount
- iscsi_storage
- name: Guardrail - ensure required mountpoints are mounted
ansible.builtin.command: "findmnt -n {{ item.path }}"
register: _findmnt
changed_when: false
failed_when: _findmnt.rc != 0
loop: "{{ iscsi_targets | default([]) | map(attribute='mounts') | list | flatten }}"
loop_control:
label: "{{ item.path }}"
tags:
- iscsi
- iscsi_mount
- iscsi_storage