Linux lun mount and format/filesystem

i am newbie on ansible
i wanted to do the below task using ansible , is there any playbook for

  1. Discovering an iscsi target
  2. Login in
  3. rescanning iscsi bus
  4. formatting the newly discovered lun
  5. creating filesystem on it.
  6. updating /etc/fstab with newly mounted

Hi,
I did this in the past for block storage, guessing something similar to this example, I’ve not formatted the devices as this was for mounting a clone

tasks:

Rescan storage layer to pull in new devices to host

Example here is for emulex hba

  • name: Rescan HBA
    command: /usr/bin/rescan-scsi-bus.sh

  • name: unmount filesystems by label
    mount:
    path: “{{ item }}”
    state: unmounted
    with_items:

  • /database

  • /reports

  • /logs

  • name: Create Directory
    file:
    path: “{{ item }}”
    state: directory
    with_items:

  • /database

  • /reports

  • /logs

  • name: Mount filesystems by label
    mount:
    path: “{{ item.mountpoint }}”
    src: LABEL=“{{ item.label }}”
    fstype: ext4
    state: mounted
    with_items:

  • { label: ‘database’, mountpoint: ‘/database’}

  • { label: ‘reports’, mountpoint: ‘/reports’}

  • { label: ‘logs’, mountpoint: ‘/logs’}

Thank you Paul.

Hello,
I have created below playbook, but i have not tested on live
check if its work for you.