Windows Assign a mount point folder path to a drive : Ansible module ???

470 views
Skip to first unread message

Sandeep G

unread,
Apr 21, 2021, 9:36:03 AM4/21/21
to Ansible Project

 have created a playbook for

1-Initialize a disk : USING win_initialize_disk

2-Create partition with drive letter (fullsize using -1) : USING win_partition

3- Full format the newly created partition (6 drives D,E,F,G,H,I)as NTFS and label it: USING win_format


Now my need is i have to create only d and F drive , and mount other partitions as mount volumes under F drive .


i couldn't find any modules for win mount volume (Mount ntfs folder), Kindly help.


I need output like  Only d and F is assigned and labelled and rest of the partitions should be under F as mounted volume/folder(There is no drive letters assigned to rest of the partitions (all are assigned under F drive as mount point))

Kindly help me on Ansible module way

jmul...@gmail.com

unread,
Apr 27, 2021, 10:53:53 AM4/27/21
to Ansible Project
This is how I created the mountpoint after add the virtual disk on 2016 and above servers

- name: Online | Initialize | Format SQL Disk - Mountpoint
  win_shell: |
    $Disk = @(Get-Disk | where-object{$_.OperationalStatus -eq 'Offline' -or $_.PartitionStyle -eq 'RAW'} | sort Number )
    if($Disk.count -eq 1 ){
        try{
            $Disk | Initialize-Disk -PartitionStyle GPT -ErrorAction SilentlyContinue
            $Disk | New-Partition -UseMaximumSize -DriveLetter "E"
            $Partition = Get-Disk -Number $Disk[0].Number | Get-Partition | where{$_.type -eq 'Basic'}
            $Partition | Format-Volume -FileSystem NTFS -Confirm:$false -AllocationUnitSize 65536 -NewFileSystemLabel "MOUNTPOINT (1:0)" 
        }
        catch{
            $_.exception
        }
    }



and this is how i added the mountpoints to it

---
- name: Online | Initialize | Format SQL Disk - {{ drive_label }}
  win_shell: |
    $Disk = @(Get-Disk | where-object{$_.OperationalStatus -eq 'Offline' -or $_.PartitionStyle -eq 'RAW'} | sort Number )
    if($Disk.count -eq 1 ){
        try{
            $Disk | Initialize-Disk -PartitionStyle GPT -ErrorAction SilentlyContinue
            $Disk | New-Partition -UseMaximumSize 
            $Partition = Get-Disk -Number $Disk[0].Number | Get-Partition | where{$_.type -eq 'Basic'}
            $Partition | Format-Volume -FileSystem NTFS -Confirm:$false -AllocationUnitSize 65536 -NewFileSystemLabel "DATA (2:0)" 
            New-Item -ItemType Directory -Path "E:\DATA"
            $Partition | Add-PartitionAccessPath -AccessPath "E:\DATA"
        }
        catch{
            $_.exception
        }
    }
Reply all
Reply to author
Forward
0 new messages