--- - name: Ensure /data is mounted from serverd iSCSI target hosts: initiators become: true tasks: - name: the iscsi-initiator-utils package is installed yum: name: iscsi-initiator-utils state: present - name: the IQN is set for the initiator #FIXME: see "ansible-doc template" for some examples. # Deploy the templates/initiatorname.iscsi.j2 template file notify: restart iscsid # Forces the handler to run so that the iscsid service is restarted # and is aware of the new initiator IQN - meta: flush_handlers - name: the iSCSI target is discovered and available #FIXME: see "ansible-doc open_iscsi" for some examples. # The target is iqn.2014-06.com.example:serverd and the portal is # 172.25.250.13 (port 3260) # Make sure that the target is automatically connected at startup. register: target - name: display the discovered devices debug: var: target['devicenodes'] - name: the new device is formatted and mounted under /data include_role: name: rhel-system-roles.storage vars: storage_volumes: - name: devdata state: present type: disk disks: - "{{ target['devicenodes'][0] }}" #FIXME: see /usr/share/doc/rhel-system-roles/storage/README.md # Set the mount point to /data, the file system type to xfs, # and add the _netdev mount option. handlers: - name: restart iscsid service: name: iscsid state: restarted