playbook.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ---
  2. - name: Ensure /data is mounted from serverd iSCSI target
  3. hosts: initiators
  4. become: true
  5. tasks:
  6. - name: the iscsi-initiator-utils package is installed
  7. yum:
  8. name: iscsi-initiator-utils
  9. state: present
  10. - name: the IQN is set for the initiator
  11. template:
  12. src: templates/initiatorname.iscsi.j2
  13. dest: /etc/iscsi/initiatorname.iscsi
  14. owner: root
  15. group: root
  16. mode: 644
  17. notify: restart iscsid
  18. # Forces the handler to run so that the iscsid service is restarted
  19. # and is aware of the new initiator IQN
  20. - meta: flush_handlers
  21. - name: the iSCSI target is discovered and available
  22. open_iscsi:
  23. portal: 172.25.250.13
  24. port: 3260
  25. target: iqn.2014-06.com.example:serverd
  26. discover: yes
  27. login: yes
  28. register: target
  29. - name: display the discovered devices
  30. debug:
  31. var: target['devicenodes']
  32. - name: the new device is formatted and mounted under /data
  33. include_role:
  34. name: rhel-system-roles.storage
  35. vars:
  36. storage_volumes:
  37. - name: devdata
  38. state: present
  39. type: disk
  40. disks:
  41. - "{{ target['devicenodes'][0] }}"
  42. mount_point: /data
  43. fs_type: xfs
  44. mount_points: '_netdev'
  45. #FIXME: see /usr/share/doc/rhel-system-roles/storage/README.md
  46. # Set the mount point to /data, the file system type to xfs,
  47. # and add the _netdev mount option.
  48. handlers:
  49. - name: restart iscsid
  50. service:
  51. name: iscsid
  52. state: restarted