My Profile Photo Title

Thoughts about DevOps and automation from a Windows guy


POSHOrigin - Sharing Configurations feature image

POSHOrigin - Sharing Configurations

This article is Part 6 in a 9-Part series about POSHOrigin, a PowerShell module that aims to assist you in managing your Infrastructure via custom PowerShell DSC resources.

POSHOrigin on GitHub→

Sharing Configurations

Some resource definitions inside your configuration file may have a large number of options associated with them and you may find yourself repeating common configuration options across your resources. For this reason, configuration snippets can be created that will be loaded into your resource configuration when Get-POSHOriginConfig is executed. These options are stored inside a file with the .psd1 extension. This is best used when the option for the resource is expecting a hashtable or an array. You could use this with simple strings or integers but it will be less useful. You reference the name of this configuration snippet (minus the .psd1 extension) using the Get-POSHDefault function

standard_disks.psd1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@(
    @{
        name = 'Hard disk 1'
        sizeGB = 50
        type = 'flat'
        format = 'Thick'
        volumeName = 'C'
        volumeLabel = 'NOS'
        blockSize = 4096
    },
    @{
       name = 'Hard disk 2'
       sizeGB = 100
       type = 'flat'
       format = 'Thick'
       volumeName = 'D'
       volumeLabel = 'Data'
       blockSize = 4096
    }
)
my_vm_config.ps1
1
2
3
4
5
6
7
8
resource 'vsphere:vm' 'VM01' @{
    ensure = 'present'
    description = 'Test VM'
    ###
    # Other options omitted for brevity
    ###
    disks = Get-POSHDefault 'standard_disks'
}
Sharing is caring