Add cloud image template functionality

This commit is contained in:
Alphaeus Mote
2025-05-09 16:49:09 -04:00
parent 4df222b36b
commit d76c9fb247
21 changed files with 3127 additions and 3 deletions
@@ -0,0 +1,148 @@
# Get-ProxmoxCloudImage
Gets available cloud images from repositories.
## Syntax
```powershell
Get-ProxmoxCloudImage
[-Distribution <String>]
[-Release <String>]
[-Variant <String>]
[-Force]
[<CommonParameters>]
```
## Description
The `Get-ProxmoxCloudImage` cmdlet gets available cloud images from repositories. You can filter the results by distribution, release, and variant.
## Parameters
### -Distribution
The distribution to filter by (e.g., "ubuntu", "debian").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Release
The release version to filter by (e.g., "22.04", "11").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Variant
The image variant to filter by (e.g., "server", "minimal").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Force
Force refresh of the cloud image cache.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.CloudImages.CloudImage
## Notes
- This cmdlet caches the cloud image metadata to improve performance. Use the `-Force` parameter to refresh the cache.
- The cmdlet supports Ubuntu and Debian cloud images.
## Examples
### Example 1: Get all available cloud images
```powershell
Get-ProxmoxCloudImage
```
This example gets all available cloud images from all supported repositories.
### Example 2: Get Ubuntu cloud images
```powershell
Get-ProxmoxCloudImage -Distribution "ubuntu"
```
This example gets all available Ubuntu cloud images.
### Example 3: Get Ubuntu 22.04 cloud images
```powershell
Get-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04"
```
This example gets all available Ubuntu 22.04 cloud images.
### Example 4: Get Ubuntu 22.04 server cloud images
```powershell
Get-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server"
```
This example gets all available Ubuntu 22.04 server cloud images.
### Example 5: Force refresh of the cloud image cache
```powershell
Get-ProxmoxCloudImage -Force
```
This example forces a refresh of the cloud image cache and gets all available cloud images.
## Related Links
- [Save-ProxmoxCloudImage](Save-ProxmoxCloudImage.md)
- [New-ProxmoxCloudImageTemplate](New-ProxmoxCloudImageTemplate.md)
@@ -0,0 +1,196 @@
# Invoke-ProxmoxCloudImageCustomization
Customizes a cloud image.
## Syntax
```powershell
Invoke-ProxmoxCloudImageCustomization
-ImagePath <String>
[-Resize <Int32>]
[-ConvertTo <String>]
[-Packages <String[]>]
[-Commands <String[]>]
[-Scripts <String[]>]
[-OutputPath <String>]
[<CommonParameters>]
```
## Description
The `Invoke-ProxmoxCloudImageCustomization` cmdlet customizes a cloud image by resizing it, converting it to a different format, adding packages, or running commands or scripts.
## Parameters
### -ImagePath
The path to the cloud image file.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -Resize
The new size of the image in GB.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ConvertTo
The format to convert the image to (e.g., "qcow2", "raw").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Packages
The packages to install in the image.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Commands
The commands to run in the image.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Scripts
The scripts to run in the image.
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -OutputPath
The output path for the customized image. If not specified, the original image will be modified.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### System.String
The path to the cloud image file.
## Outputs
### System.String
The path to the customized image.
## Notes
- This cmdlet requires the QEMU tools to be installed on the system.
- The `-Packages`, `-Commands`, and `-Scripts` parameters are not fully implemented yet.
- The cmdlet shows a progress bar during the customization process.
## Examples
### Example 1: Resize a cloud image to 20GB
```powershell
Invoke-ProxmoxCloudImageCustomization -ImagePath "C:\Images\ubuntu-22.04-server-cloudimg-amd64.img" -Resize 20
```
This example resizes the specified cloud image to 20GB.
### Example 2: Convert a cloud image to qcow2 format
```powershell
Invoke-ProxmoxCloudImageCustomization -ImagePath "C:\Images\ubuntu-22.04-server-cloudimg-amd64.img" -ConvertTo "qcow2"
```
This example converts the specified cloud image to qcow2 format.
### Example 3: Resize and convert a cloud image
```powershell
Invoke-ProxmoxCloudImageCustomization -ImagePath "C:\Images\ubuntu-22.04-server-cloudimg-amd64.img" -Resize 20 -ConvertTo "qcow2" -OutputPath "C:\Images\ubuntu-22.04-server-cloudimg-amd64-custom.qcow2"
```
This example resizes the specified cloud image to 20GB, converts it to qcow2 format, and saves it to the specified output path.
### Example 4: Customize a cloud image with packages and commands
```powershell
Invoke-ProxmoxCloudImageCustomization -ImagePath "C:\Images\ubuntu-22.04-server-cloudimg-amd64.img" -Packages "nginx", "postgresql" -Commands "systemctl enable nginx", "systemctl enable postgresql"
```
This example installs the specified packages and runs the specified commands in the cloud image.
## Related Links
- [Save-ProxmoxCloudImage](Save-ProxmoxCloudImage.md)
- [New-ProxmoxCloudImageTemplate](New-ProxmoxCloudImageTemplate.md)
@@ -0,0 +1,321 @@
# New-ProxmoxCloudImageTemplate
Creates a template from a cloud image.
## Syntax
```powershell
New-ProxmoxCloudImageTemplate
-Node <String>
-Name <String>
-Distribution <String>
-Release <String>
[-Variant <String>]
-Storage <String>
[-Memory <Int32>]
[-Cores <Int32>]
[-DiskSize <Int32>]
[-NetworkType <String>]
[-Bridge <String>]
[-ScsiController <String>]
[-Connection <ProxmoxConnection>]
[<CommonParameters>]
```
```powershell
New-ProxmoxCloudImageTemplate
-Node <String>
-Name <String>
-ImagePath <String>
-Storage <String>
[-Memory <Int32>]
[-Cores <Int32>]
[-DiskSize <Int32>]
[-NetworkType <String>]
[-Bridge <String>]
[-ScsiController <String>]
[-Connection <ProxmoxConnection>]
[<CommonParameters>]
```
## Description
The `New-ProxmoxCloudImageTemplate` cmdlet creates a template from a cloud image. You can either specify a distribution, release, and variant to download a cloud image automatically, or provide a path to a local cloud image file.
## Parameters
### -Node
The node on which to create the template.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Name
The name of the template.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Distribution
The distribution of the cloud image (e.g., "ubuntu", "debian").
```yaml
Type: String
Parameter Sets: ByDistribution
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Release
The release version of the cloud image (e.g., "22.04", "11").
```yaml
Type: String
Parameter Sets: ByDistribution
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Variant
The variant of the cloud image (e.g., "server", "minimal").
```yaml
Type: String
Parameter Sets: ByDistribution
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ImagePath
The path to a local cloud image file.
```yaml
Type: String
Parameter Sets: ByImagePath
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Storage
The storage on which to create the template.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Memory
The amount of memory in MB for the template.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 1024
Accept pipeline input: False
Accept wildcard characters: False
```
### -Cores
The number of CPU cores for the template.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
```
### -DiskSize
The disk size in GB for the template.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: 10
Accept pipeline input: False
Accept wildcard characters: False
```
### -NetworkType
The network interface type for the template.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: virtio
Accept pipeline input: False
Accept wildcard characters: False
```
### -Bridge
The network bridge for the template.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: vmbr0
Accept pipeline input: False
Accept wildcard characters: False
```
### -ScsiController
The SCSI controller type for the template.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: virtio-scsi-pci
Accept pipeline input: False
Accept wildcard characters: False
```
### -Connection
The connection to the Proxmox VE server.
```yaml
Type: ProxmoxConnection
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.Models.ProxmoxVM
## Notes
- This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection.
- The cmdlet creates a VM from a cloud image and converts it to a template.
- The template includes a Cloud-Init drive for easy customization.
- The cmdlet shows progress bars during the download and upload processes.
## Examples
### Example 1: Create a template from an Ubuntu 22.04 cloud image
```powershell
New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04" -Distribution "ubuntu" -Release "22.04" -Storage "local-lvm" -Memory 2048 -Cores 2 -DiskSize 20
```
This example creates a template named "ubuntu-22.04" from an Ubuntu 22.04 cloud image on the node "pve1".
### Example 2: Create a template from a local cloud image file
```powershell
New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04" -ImagePath "C:\Images\ubuntu-22.04-server-cloudimg-amd64.img" -Storage "local-lvm" -Memory 2048 -Cores 2 -DiskSize 20
```
This example creates a template named "ubuntu-22.04" from a local cloud image file on the node "pve1".
### Example 3: Create a template with custom network settings
```powershell
New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04" -Distribution "ubuntu" -Release "22.04" -Storage "local-lvm" -Memory 2048 -Cores 2 -DiskSize 20 -NetworkType "virtio" -Bridge "vmbr1"
```
This example creates a template named "ubuntu-22.04" from an Ubuntu 22.04 cloud image on the node "pve1" with custom network settings.
## Related Links
- [Get-ProxmoxCloudImage](Get-ProxmoxCloudImage.md)
- [Save-ProxmoxCloudImage](Save-ProxmoxCloudImage.md)
- [Set-ProxmoxVMCloudInit](Set-ProxmoxVMCloudInit.md)
- [New-ProxmoxVMFromTemplate](New-ProxmoxVMFromTemplate.md)
@@ -0,0 +1,153 @@
# Save-ProxmoxCloudImage
Downloads a cloud image.
## Syntax
```powershell
Save-ProxmoxCloudImage
-Distribution <String>
-Release <String>
[-Variant <String>]
[-OutputPath <String>]
[-Force]
[<CommonParameters>]
```
## Description
The `Save-ProxmoxCloudImage` cmdlet downloads a cloud image from a repository. You can specify the distribution, release, and variant to download.
## Parameters
### -Distribution
The distribution to download (e.g., "ubuntu", "debian").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Release
The release version to download (e.g., "22.04", "11").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Variant
The image variant to download (e.g., "server", "minimal").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -OutputPath
The output path where the image will be saved. If not specified, the image will be saved to the default download directory.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Force
Force download even if the image already exists.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### System.String
The path to the downloaded image.
## Notes
- This cmdlet downloads cloud images to a local cache directory by default. Use the `-OutputPath` parameter to specify a different location.
- The cmdlet supports Ubuntu and Debian cloud images.
- The cmdlet shows a progress bar during the download.
## Examples
### Example 1: Download an Ubuntu 22.04 server cloud image
```powershell
Save-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server"
```
This example downloads an Ubuntu 22.04 server cloud image to the default download directory.
### Example 2: Download a Debian 11 generic cloud image to a specific location
```powershell
Save-ProxmoxCloudImage -Distribution "debian" -Release "11" -Variant "generic" -OutputPath "C:\Images\debian-11.qcow2"
```
This example downloads a Debian 11 generic cloud image to the specified location.
### Example 3: Force download of an Ubuntu 22.04 server cloud image
```powershell
Save-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server" -Force
```
This example forces the download of an Ubuntu 22.04 server cloud image, even if it already exists in the cache.
## Related Links
- [Get-ProxmoxCloudImage](Get-ProxmoxCloudImage.md)
- [Invoke-ProxmoxCloudImageCustomization](Invoke-ProxmoxCloudImageCustomization.md)
- [New-ProxmoxCloudImageTemplate](New-ProxmoxCloudImageTemplate.md)
@@ -0,0 +1,203 @@
# Set-ProxmoxVMCloudInit
Sets Cloud-Init configuration for a VM.
## Syntax
```powershell
Set-ProxmoxVMCloudInit
-Node <String>
-VMID <Int32>
[-Username <String>]
[-Password <SecureString>]
[-SSHKey <String>]
[-IPConfig <String>]
[-DNS <String>]
[-Connection <ProxmoxConnection>]
[<CommonParameters>]
```
## Description
The `Set-ProxmoxVMCloudInit` cmdlet sets Cloud-Init configuration for a VM. Cloud-Init is used to customize cloud images at boot time.
## Parameters
### -Node
The node on which the VM is located.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VMID
The ID of the VM.
```yaml
Type: Int32
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Username
The username for Cloud-Init.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Password
The password for Cloud-Init.
```yaml
Type: SecureString
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SSHKey
The SSH public key for Cloud-Init.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -IPConfig
The IP configuration for Cloud-Init (e.g., "dhcp" or "ip=192.168.1.100/24,gw=192.168.1.1").
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DNS
The DNS servers for Cloud-Init (comma-separated).
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Connection
The connection to the Proxmox VE server.
```yaml
Type: ProxmoxConnection
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## Inputs
### None
## Outputs
### PSProxmox.Models.ProxmoxVM
## Notes
- This cmdlet requires a connection to a Proxmox VE server. Use `Connect-ProxmoxServer` to establish a connection.
- The VM must have a Cloud-Init drive attached.
- The Cloud-Init configuration is applied when the VM is started.
## Examples
### Example 1: Set Cloud-Init configuration for a VM
```powershell
$password = ConvertTo-SecureString "password" -AsPlainText -Force
Set-ProxmoxVMCloudInit -Node "pve1" -VMID 100 -Username "admin" -Password $password -SSHKey "ssh-rsa AAAA..." -IPConfig "dhcp" -DNS "8.8.8.8,8.8.4.4"
```
This example sets Cloud-Init configuration for VM 100 on node "pve1" with the specified username, password, SSH key, IP configuration, and DNS servers.
### Example 2: Set Cloud-Init configuration with static IP
```powershell
$password = ConvertTo-SecureString "password" -AsPlainText -Force
Set-ProxmoxVMCloudInit -Node "pve1" -VMID 100 -Username "admin" -Password $password -IPConfig "ip=192.168.1.100/24,gw=192.168.1.1"
```
This example sets Cloud-Init configuration for VM 100 on node "pve1" with a static IP address.
### Example 3: Set Cloud-Init configuration with SSH key only
```powershell
Set-ProxmoxVMCloudInit -Node "pve1" -VMID 100 -Username "admin" -SSHKey "ssh-rsa AAAA..."
```
This example sets Cloud-Init configuration for VM 100 on node "pve1" with the specified username and SSH key.
## Related Links
- [New-ProxmoxCloudImageTemplate](New-ProxmoxCloudImageTemplate.md)
- [New-ProxmoxVMFromTemplate](New-ProxmoxVMFromTemplate.md)