ricsanfre.iscsi_target

Ansible 角色:iSCSI 目标

此角色在 Linux 主机上使用 targetcli 配置基于 Linux-LIO 的 iSCSI 目标。

此外,角色还包含自己的 Python 模块,用于与 targetcli 命令交互,可单独使用以实现更高级的功能。这些模块实现了检查、创建和删除。

注意:有关 LIO 和 Target 的文档可以在 这里 找到。

要求

此角色不创建任何磁盘/分区/LV。预期这些已经存在于机器上或由其他角色创建。例如:ricsanfre.storage

角色变量

要配置 iSCSI 目标,使用以下嵌套变量来定义配置的样子。

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

依赖关系

无。

示例剧本

该示例使用 ricsanfre.storage 角色创建用于配置 iSCSI 目标的逻辑卷。

- 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

许可证

MIT/BSD

作者信息

作者:Ricardo Sanchez(ricsanfre),基于 Ondrej Famera 从 targetcli 的开发。

关于项目

Configure iSCSI Target role

安装
ansible-galaxy install ricsanfre.iscsi_target
许可证
mit
下载
8k
拥有者
Telecom engineer.