mirror of
https://github.com/dredx/prole.git
synced 2026-09-27 09:34:30 +00:00
44 lines
1.5 KiB
YAML
44 lines
1.5 KiB
YAML
---
|
|
- name: Ensure node record exists for target
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -T {{ t.iqn }} -p {{ iscsi_portal }}
|
|
register: node_check
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Create node record if missing
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -o new -T {{ t.iqn }} -p {{ iscsi_portal }}
|
|
when: node_check.rc != 0
|
|
|
|
- name: Configure CHAP authmethod
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -T {{ t.iqn }} -p {{ iscsi_portal }}
|
|
--op update -n node.session.auth.authmethod -v CHAP
|
|
when: (t.chap_user | default('')) | length > 0
|
|
|
|
- name: Configure CHAP username
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -T {{ t.iqn }} -p {{ iscsi_portal }}
|
|
--op update -n node.session.auth.username -v {{ t.chap_user }}
|
|
when: (t.chap_user | default('')) | length > 0
|
|
|
|
- name: Configure CHAP password
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -T {{ t.iqn }} -p {{ iscsi_portal }}
|
|
--op update -n node.session.auth.password -v {{ t.chap_password }}
|
|
when: (t.chap_user | default('')) | length > 0
|
|
no_log: true
|
|
|
|
- name: Ensure iSCSI autologin
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -T {{ t.iqn }} -p {{ iscsi_portal }}
|
|
--op update -n node.startup -v automatic
|
|
|
|
- name: Login to target
|
|
ansible.builtin.command: >
|
|
iscsiadm -m node -T {{ t.iqn }} -p {{ iscsi_portal }} --login
|
|
register: login
|
|
changed_when: false
|
|
failed_when: login.rc not in [0, 15] # 15 is "already logged in" on many builds
|