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.
- Part 1 - POSHOrigin - Summary
- Part 2 - POSHOrigin - Installation
- Part 3 - POSHOrigin - Configuration File
- Part 4 - POSHOrigin - Defaults File
- Part 5 - POSHOrigin - Load, Test, and Execute Configurations
- Part 6 - POSHOrigin - Sharing Configurations <<
- Part 7 - POSHOrigin - Credential Resolvers
- Part 8 - POSHOrigin - Examples
- Part 9 - POSHOrigin - Wrapping Up
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'
}