feat!: set iscsi task to run on docker host, refs #31
All checks were successful
Deploy / Prepare Build (push) Successful in 4m52s
All checks were successful
Deploy / Prepare Build (push) Successful in 4m52s
This commit is contained in:
@ -4,15 +4,14 @@
|
||||
name: open-iscsi
|
||||
state: present
|
||||
|
||||
- name: Ensure open-iscsi is installed
|
||||
- name: Ensure parted is installed
|
||||
package:
|
||||
name: parted
|
||||
state: present
|
||||
|
||||
- name: Discover iSCSI targets
|
||||
command: iscsiadm -m discovery -t sendtargets -p "10.10.10.2"
|
||||
command: sudo iscsiadm -m discovery -t sendtargets -p "10.10.10.2"
|
||||
register: iscsi_discovery
|
||||
changed_when: False
|
||||
|
||||
- name: Set target_iqn variable based on discovery
|
||||
set_fact:
|
||||
@ -20,6 +19,15 @@
|
||||
loop: "{{ iscsi_discovery.stdout_lines }}"
|
||||
when: item.startswith("10.10.10.2")
|
||||
|
||||
- name: Check if iSCSI target is already connected
|
||||
command: iscsiadm -m session
|
||||
register: iscsi_sessions
|
||||
changed_when: false
|
||||
|
||||
- name: Connect to iSCSI target
|
||||
command: sudo iscsiadm -m node -T "{{ target_iqn }}" -p "10.10.10.2" --login
|
||||
when: target_iqn is defined and target_iqn not in iscsi_sessions.stdout
|
||||
|
||||
- name: Fail if no target_iqn found
|
||||
fail:
|
||||
msg: "No target IQN found for iSCSI server IP 10.10.10.2"
|
||||
@ -57,12 +65,12 @@
|
||||
|
||||
- name: Create mount point
|
||||
file:
|
||||
path: /mnt/data
|
||||
path: /data
|
||||
state: directory
|
||||
|
||||
- name: Mount iSCSI target
|
||||
mount:
|
||||
path: /mnt/data
|
||||
path: /data
|
||||
src: "{{ iscsi_device }}1" # Mount the new partition
|
||||
fstype: ext4
|
||||
state: mounted
|
||||
@ -70,5 +78,5 @@
|
||||
- name: Ensure iSCSI target is mounted at boot
|
||||
lineinfile:
|
||||
path: /etc/fstab
|
||||
line: "{{ iscsi_device }}1 /mnt/iscsi ext4 defaults 0 0"
|
||||
line: "{{ iscsi_device }}1 /data ext4 defaults 0 0"
|
||||
state: present
|
||||
|
Reference in New Issue
Block a user