ricsanfre.iscsi_target
Ansible-Rolle: iSCSI-Ziel
Diese Rolle konfiguriert ein iSCSI-Ziel basierend auf Linux-LIO auf einem Linux-Host unter Verwendung von targetcli
.
Zusätzlich enthält diese Rolle eigene Python-Module, um mit dem targetcli
-Befehl zu interagieren, die separat für fortgeschrittenere Dinge verwendet werden können. Die Module implementieren Überprüfungen, Erstellungen und Löschungen.
HINWEIS: Dokumentationen zu LIO und Ziel sind [hier] (https://linux-iscsi.org/wiki/Main_Page) zu finden.
Voraussetzungen
Diese Rolle erstellt keine Festplatten/Partitionen/LVs. Es wird erwartet, dass diese bereits auf der Maschine vorhanden sind oder von einer anderen Rolle erstellt wurden. Zum Beispiel: ricsanfre.storage
Rollenvariablen
Um das iSCSI-Ziel zu konfigurieren, wird folgende verschachtelte Variable verwendet, die definiert, wie die Konfiguration aussehen soll.
iscsi_targets:
- name: "iqn.2021-07.com.ricsanfre:target_server"
disks:
- name: lun_node1
path: /dev/vg_iscsi/vg_iscsi_lv_node1
type: block
lunid: 0
- name: lun_node2
path: /dev/vg_iscsi/vg_iscsi_lv_node2
type: block
lunid: 1
- name: lun_node3
path: /dev/vg_iscsi/vg_iscsi_lv_node3
type: block
lunid: 2
- name: lun_node4
path: /dev/vg_iscsi/vg_iscsi_lv_node4
type: block
lunid: 3
initiators:
- name: iqn.2021-07.com.ricsanfre:node1
authentication:
userid: node1
password: passwd1
userid_mutual: sharedkey
password_mutual: sharedsecret
mapped_luns:
- mapped_lunid: 0
lunid: 0
- mapped_lunid: 1
lunid: 2
- name: iqn.2021-07.com.ricsanfre:node2
authentication:
userid: node2
password: passwd2
mapped_luns:
- mapped_lunid: 0
lunid: 1
- mapped_lunid: 1
lunid: 3
write_protect: 1
portals:
- ip: 192.168.1.45
port: 5555
- ip: 192.168.2.10
Abhängigkeiten
Keine.
Beispiel-Playbook
Dieses Beispiel nutzt die Rolle ricsanfre.storage
, um die logischen Volumes zu erstellen, die zur Konfiguration des iSCSI-Ziels verwendet werden.
- hosts: all
become: true
gather_facts: true
vars:
storage_partitions:
- name: /dev/vdb
number: 1
flags:
- lvm
part_end: 1GB
storage_volumegroups:
- name: vg_iscsi
devices:
- /dev/vdb1
storage_volumes:
- name: vg_iscsi_lv_node1
vg: vg_iscsi
size: 100
- name: vg_iscsi_lv_node2
vg: vg_iscsi
size: 100
- name: vg_iscsi_lv_node3
vg: vg_iscsi
size: 100
- name: vg_iscsi_lv_node4
vg: vg_iscsi
size: 100
iscsi_targets:
- name: "iqn.2021-07.com.ricsanfre:{{ ansible_facts['nodename'] }}"
disks:
- name: lun_node1
path: /dev/vg_iscsi/vg_iscsi_lv_node1
type: block
lunid: 0
- name: lun_node2
path: /dev/vg_iscsi/vg_iscsi_lv_node2
type: block
lunid: 1
- name: lun_node3
path: /dev/vg_iscsi/vg_iscsi_lv_node3
type: block
lunid: 2
- name: lun_node4
path: /dev/vg_iscsi/vg_iscsi_lv_node4
type: block
lunid: 3
initiators:
- name: iqn.2021-07.com.ricsanfre:node1
authentication:
userid: node1
password: passwd1
mapped_luns:
- mapped_lunid: 0
lunid: 0
- mapped_lunid: 1
lunid: 2
- name: iqn.2021-07.com.ricsanfre:node2
authentication:
userid: node2
password: passwd2
mapped_luns:
- mapped_lunid: 0
lunid: 1
- mapped_lunid: 1
lunid: 3
write_protect: 1
portals:
- ip: "{{ ansible_default_ipv4.address | default(ansible_all_ipv4_addresses[0]) }}"
roles:
- ricsanfre.storage
- ricsanfre.iscsi_target
Lizenz
MIT/BSD
Autoreninformation
Erstellt von Ricardo Sanchez (ricsanfre), basierend auf der Entwicklung von targetcli von Ondrej Famera ondrej-xa2iel8u@famera.cz
ansible-galaxy install ricsanfre.iscsi_target