---
- name: Install required packages
  package:
    name: '{{ item }}'
    state: latest
  with_items:
  - iscsi-initiator-utils
  - device-mapper-multipath
  
- name: Write iscsi initiator name
  lineinfile:
    regexp: '^(InitiatorName=).*'
    dest: /etc/iscsi/initiatorname.iscsi
    line: '\1{{ iscsi_initiator_name }}'
    state: present
    backrefs: yes
    
- name: Write multipath conf file
  copy:
    src: ../templates/multipath.conf
    dest: /etc/multipath.conf
      
- name: Enable and Start neccessary services
  service:
    name: '{{ item }}'
    state: started
    enabled: yes
  with_items:
  - iscsid
  - multipathd