playbook.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. - name: Ensure /iscsidisk is mounted from serverd iSCSI target
  3. hosts: initiators
  4. become: true
  5. tasks:
  6. - name: the iSCSI initiator software 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: 0640
  17. notify: restart iscsid
  18. - meta: flush_handlers
  19. - name: the iSCSI target is discovered and available
  20. open_iscsi:
  21. portal: 172.25.250.13
  22. port: '3260'
  23. target: iqn.2014-06.com.example:store1
  24. discover: yes
  25. login: yes
  26. register: target
  27. - name: display the discovered devices
  28. debug:
  29. msg: "The new device is {{ target['devicenodes'][0] }}"
  30. - name: the new device is formatted and mounted under /iscsidisk
  31. include_role:
  32. name: rhel-system-roles.storage
  33. vars:
  34. storage_volumes:
  35. - name: devdata
  36. state: present
  37. type: disk
  38. disks:
  39. - "{{ target['devicenodes'][0] }}"
  40. mount_point: /iscsidisk
  41. fs_type: ext4
  42. mount_options: '_netdev'
  43. handlers:
  44. - name: restart iscsid
  45. service:
  46. name: iscsid
  47. state: restarted