DSC / StorageDSC - Supported? Multiple resource name definitions?

102 views
Skip to first unread message

Alexander Ray

unread,
Mar 7, 2018, 11:57:28 AM3/7/18
to Puppet Users
I am trying to write a puppet module to automate configuring the disk layout of a certain type of server, using DSC.  A typical example (https://github.com/PowerShell/StorageDsc/wiki/Disk) is as follows:

Configuration Example
{
   
Import-DSCResource -ModuleName StorageDsc

   
Node localhost
   
{
       
WaitForDisk Disk2
       
{
             
DiskId = 2
             
RetryIntervalSec = 60
             
RetryCount = 60
       
}

       
Disk GVolume
       
{
             
DiskId = 2
             
DriveLetter = 'G'
             
Size = 10GB
             
DependsOn = '[WaitForDisk]Disk2'
       
}

       
Disk JVolume
       
{
             
DiskId = 2
             
DriveLetter = 'J'
             
FSLabel = 'Data'
             
DependsOn = '[Disk]GVolume'
       
}

       
WaitForDisk Disk3
       
{
             
DiskId = 3
             
RetryIntervalSec = 60
             
RetryCount = 60
       
}

       
Disk SVolume
       
{
             
DiskId = 3
             
DriveLetter = 'S'
             
Size = 100GB
             
FSFormat = 'ReFS'
             
AllocationUnitSize = 64KB
             
DependsOn = '[WaitForDisk]Disk3'
       
}
   
}
}

What I'm not sure about is how to handle the equivalent puppet manifest - I know WaitFor* is not supported, but the other problem is the duplicate resource names:

class myclass {
  dsc_storagedsc
{ 'Disk':
    dsc_name
=> 'DriveOne',
    dsc_diskid
=> 3
 
}
  dsc_storagedsc
{ 'Disk':
    dsc_name
=> 'DriveTwo',
    dsc_diskid
=> 4
 
}
}

I'm not sure how I would 'require' those in other parts of the manifest.  Also, puppet doesn't seem to like dsc_storagedsc either, though I can use dsc_windowsfeature, reboot, etc.  I also tried dsc_storage.

James Pogran

unread,
Mar 7, 2018, 1:47:46 PM3/7/18
to puppet...@googlegroups.com
So, the part you're tripping up on is using the DSC Resource module name (StorageDsc) for the DSC Resource name (Disk). You can take your existing DSC Configuration script and turn it directly into a Puppet manifest by keeping the DSC Resouce names like so:

dsc_disk{ 'GVolume':
  dsc_diskid      => 2
  dsc_driveletter => 'G'
  dsc_size        => 10GB
}

dsc_disk{ 'JVolume':
  dsc_diskid      => 2
  dsc_driveletter => 'J'
  dsc_fslabel     => 'Data'
}

dsc_disk{ 'SVolume':
  dsc_diskid             => 3
  dsc_driveletter        => 'S'
  dsc_size               => 100GB
  dsc_fsformat           => 'ReFS'
  dsc_allocationunitsize => 64KB
}

This uses the same labels as the DSC Configuration script, just moves them into Puppet syntax places, and adjusts the parameter names to follow the Puppet dsc module convention.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/f9968e37-bc67-4001-a17a-d6a64c01b647%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
James Pogran
Senior Software Engineer, Windows
Puppet. The shortest path to better software
Reply all
Reply to author
Forward
0 new messages