playbook.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #FIXME: see "ansible-doc template" for some examples.
  12. # Deploy the templates/initiatorname.iscsi.j2 template file
  13. notify: restart iscsid
  14. # Forces the handler to run so that the iscsid service is restarted
  15. # and is aware of the new initiator IQN
  16. - meta: flush_handlers
  17. - name: the iSCSI target is discovered and available
  18. #FIXME: see "ansible-doc open_iscsi" for some examples.
  19. # The target is iqn.2014-06.com.example:serverd and the portal is
  20. # 172.25.250.13 (port 3260)
  21. # Make sure that the target is automatically connected at startup.
  22. register: target
  23. - name: display the discovered devices
  24. debug:
  25. var: target['devicenodes']
  26. - name: the new device is formatted and mounted under /data
  27. include_role:
  28. name: rhel-system-roles.storage
  29. vars:
  30. storage_volumes:
  31. - name: devdata
  32. state: present
  33. type: disk
  34. disks:
  35. - "{{ target['devicenodes'][0] }}"
  36. #FIXME: see /usr/share/doc/rhel-system-roles/storage/README.md
  37. # Set the mount point to /data, the file system type to xfs,
  38. # and add the _netdev mount option.
  39. handlers:
  40. - name: restart iscsid
  41. service:
  42. name: iscsid
  43. state: restarted