initiator.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. - name: Ensure /data_prod is mounted from serverc iSCSI target
  3. hosts: initiators
  4. become: true
  5. tasks:
  6. - name: the iSCSI initiator software is installed
  7. yum:
  8. name: #FIXME: install the required package
  9. state: present
  10. - name: the IQN is set for the initiator
  11. copy:
  12. #FIXME: set the initiator IQN to iqn.2014-06.com.example:servera
  13. dest: #FIXME#
  14. content: "#FIXME#=iqn.2014-06.com.example:{{ ansible_facts['hostname'] }}\n"
  15. mode: '644'
  16. owner: root
  17. group: root
  18. notify: restart iscsid
  19. # Forces the handler to run so that the iscsid service is restarted
  20. # and is aware of the new initiator IQN
  21. - meta: flush_handlers
  22. - name: the iSCSI target is discovered and available
  23. open_iscsi:
  24. #FIXME: discover and log into the target.
  25. # Target IQN: iqn.2014-06.com.example:rack1
  26. # Portal: 172.25.250.12 (port 3260)
  27. portal: #FIXME#
  28. port: #FIXME#
  29. target: #FIXME#
  30. discover: yes
  31. login: yes
  32. register: target
  33. - name: display the discovered devices
  34. debug:
  35. msg: The new device is {{ target['devicenodes'][0] }}
  36. - name: the new device is formatted and mounted under /data_prod
  37. include_role:
  38. name: rhel-system-roles.storage
  39. vars:
  40. #FIXME: mount target['devicenodes'][0] into /data_prod
  41. # If the device is not yet formatted in ext4, format it.
  42. # Use the proper mount option for an iSCSI disk.
  43. storage_volumes:
  44. - name: devdata
  45. state: present
  46. type: disk
  47. disks:
  48. - "{{ target['devicenodes'][0] }}"
  49. mount_point: #FIXME#
  50. fs_type: #FIXME#
  51. mount_options: #FIXME#
  52. handlers:
  53. - name: restart iscsid
  54. service:
  55. name: iscsid
  56. state: restarted