mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 15:04:31 +00:00
50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
---
|
|
- name: Install iSCSI dependencies
|
|
ansible.builtin.package:
|
|
name:
|
|
- open-iscsi
|
|
- util-linux
|
|
state: present
|
|
|
|
- name: Ensure iscsid enabled
|
|
ansible.builtin.service:
|
|
name: iscsid
|
|
state: started
|
|
enabled: true
|
|
|
|
- name: Configure and login iSCSI targets
|
|
ansible.builtin.include_tasks: iscsi_target.yml
|
|
loop: "{{ iscsi_targets | default([]) }}"
|
|
loop_control:
|
|
loop_var: t
|
|
|
|
- name: Mount filesystems for iSCSI targets
|
|
ansible.builtin.include_tasks: iscsi_mount.yml
|
|
loop: "{{ iscsi_targets | default([]) | map(attribute='mounts') | list | flatten }}"
|
|
loop_control:
|
|
loop_var: m
|
|
|
|
- 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 }}"
|
|
|
|
- name: Guardrail - ensure /var/lib/rancher is not on SD/rootfs
|
|
ansible.builtin.command: "findmnt -n -o SOURCE /var/lib/rancher"
|
|
register: rancher_source
|
|
changed_when: false
|
|
failed_when: rancher_source.rc != 0
|
|
when: iscsi_targets is defined and iscsi_targets | length > 0
|
|
|
|
- name: Fail if /var/lib/rancher is on SD
|
|
ansible.builtin.fail:
|
|
msg: "/var/lib/rancher is on SD/rootfs ({{ rancher_source.stdout }}). Refusing to proceed."
|
|
when:
|
|
- iscsi_targets is defined
|
|
- iscsi_targets | length > 0
|
|
- rancher_source.stdout is search("mmcblk0") or rancher_source.stdout is search("/dev/mmc")
|