63 lines
1.1 KiB
YAML
63 lines
1.1 KiB
YAML
---
|
|
- name: install iSCSI packages (alpine)
|
|
apk:
|
|
name: "{{ item }}"
|
|
state: present
|
|
update_cache: yes
|
|
loop:
|
|
- open-iscsi
|
|
- open-iscsi-openrc
|
|
tags:
|
|
- pkg
|
|
when: ansible_distribution == 'Alpine'
|
|
|
|
- name: install iSCSI packages (debian)
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: present
|
|
update_cache: yes
|
|
loop:
|
|
- open-iscsi
|
|
tags:
|
|
- pkg
|
|
when: ansible_distribution == 'Debian'
|
|
|
|
- name: make netmount depends on iscsid
|
|
lineinfile:
|
|
path: /etc/conf.d/netmount
|
|
line: 'rc_need="iscsid"'
|
|
tags:
|
|
- pkg
|
|
|
|
- name: configure iSCSI
|
|
template:
|
|
src: iscsid.conf.j2
|
|
dest: /etc/iscsi/iscsid.conf
|
|
tags:
|
|
- pkg
|
|
|
|
- name: configure iSCSI initiatorname
|
|
replace:
|
|
path: /etc/iscsi/initiatorname.iscsi
|
|
regexp: ".*InitiatorName=.*"
|
|
replace: "InitiatorName={{ iscsi_session_username }}"
|
|
tags:
|
|
- pkg
|
|
|
|
- name: ensure iSCSId is running
|
|
service:
|
|
name: iscsid
|
|
enabled: yes
|
|
state: started
|
|
tags:
|
|
- pkg
|
|
|
|
- open_iscsi:
|
|
discover: yes
|
|
portal: "{{ iscsi_target.portal }}"
|
|
|
|
- open_iscsi:
|
|
login: yes
|
|
portal: "{{ iscsi_target.target }}"
|
|
automatic: yes
|