mirror of
https://github.com/Grace-Solutions/PSProxmox.git
synced 2026-08-24 13:16:29 +00:00
Add cloud image template functionality
This commit is contained in:
@@ -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)
|
||||
@@ -0,0 +1,158 @@
|
||||
# Advanced-CloudImageTemplate.ps1
|
||||
# This script demonstrates advanced usage of cloud image template functionality.
|
||||
|
||||
# Parameters
|
||||
param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$ProxmoxServer = "proxmox.example.com",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Node = "pve1",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Storage = "local-lvm",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Distribution = "ubuntu",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Release = "22.04",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Variant = "server",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[int]$MemoryMB = 2048,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[int]$Cores = 2,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[int]$DiskSizeGB = 20,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$TemplateNamePrefix = "cloud",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$VMNamePrefix = "vm",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[int]$VMCount = 3,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$SSHKeyPath = "~/.ssh/id_rsa.pub",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Username = "admin",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$Password = "SecurePassword123!",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$IPConfigTemplate = "ip=192.168.1.{0}/24,gw=192.168.1.1",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$DNS = "8.8.8.8,8.8.4.4",
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$CustomizeImage,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[switch]$StartVMs
|
||||
)
|
||||
|
||||
# Function to log messages with timestamps
|
||||
function Write-Log {
|
||||
param([string]$Message)
|
||||
Write-Host "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') - $Message"
|
||||
}
|
||||
|
||||
try {
|
||||
# Connect to the Proxmox server
|
||||
Write-Log "Connecting to Proxmox server $ProxmoxServer..."
|
||||
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
|
||||
$credential = New-Object System.Management.Automation.PSCredential($Username, $securePassword)
|
||||
Connect-ProxmoxServer -Server $ProxmoxServer -Credential $credential
|
||||
Write-Log "Connected to Proxmox server $ProxmoxServer"
|
||||
|
||||
# Get available cloud images
|
||||
Write-Log "Getting available $Distribution $Release $Variant cloud images..."
|
||||
$images = Get-ProxmoxCloudImage -Distribution $Distribution -Release $Release
|
||||
if ($images.Count -eq 0) {
|
||||
throw "No cloud images found for $Distribution $Release"
|
||||
}
|
||||
Write-Log "Found $($images.Count) cloud images"
|
||||
|
||||
# Download the cloud image
|
||||
Write-Log "Downloading $Distribution $Release $Variant cloud image..."
|
||||
$imagePath = Save-ProxmoxCloudImage -Distribution $Distribution -Release $Release -Variant $Variant
|
||||
Write-Log "Downloaded cloud image to: $imagePath"
|
||||
|
||||
# Customize the cloud image if requested
|
||||
if ($CustomizeImage) {
|
||||
Write-Log "Customizing cloud image (resizing to $DiskSizeGB GB)..."
|
||||
$imagePath = Invoke-ProxmoxCloudImageCustomization -ImagePath $imagePath -Resize $DiskSizeGB
|
||||
Write-Log "Customized cloud image: $imagePath"
|
||||
}
|
||||
|
||||
# Create a template name with timestamp
|
||||
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||
$templateName = "$TemplateNamePrefix-$Distribution-$Release-$timestamp"
|
||||
|
||||
# Create a template from the cloud image
|
||||
Write-Log "Creating template $templateName from cloud image..."
|
||||
$template = New-ProxmoxCloudImageTemplate -Node $Node -Name $templateName -ImagePath $imagePath -Storage $Storage -Memory $MemoryMB -Cores $Cores -DiskSize $DiskSizeGB
|
||||
Write-Log "Created template: $($template.Name) (VMID: $($template.VMID))"
|
||||
|
||||
# Read SSH key if path is provided
|
||||
$sshKey = $null
|
||||
if (Test-Path $SSHKeyPath) {
|
||||
$sshKey = Get-Content -Path $SSHKeyPath -Raw
|
||||
Write-Log "Read SSH key from $SSHKeyPath"
|
||||
}
|
||||
|
||||
# Create VMs from the template
|
||||
Write-Log "Creating $VMCount VMs from template $templateName..."
|
||||
$vms = @()
|
||||
for ($i = 1; $i -le $VMCount; $i++) {
|
||||
$vmName = "$VMNamePrefix-$i"
|
||||
Write-Log "Creating VM $vmName..."
|
||||
$vm = New-ProxmoxVMFromTemplate -Node $Node -TemplateName $templateName -Name $vmName
|
||||
Write-Log "Created VM: $($vm.Name) (VMID: $($vm.VMID))"
|
||||
|
||||
# Set Cloud-Init configuration for the VM
|
||||
$ipConfig = $IPConfigTemplate -f (100 + $i)
|
||||
Write-Log "Setting Cloud-Init configuration for VM $($vm.VMID) with IP $ipConfig..."
|
||||
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
|
||||
Set-ProxmoxVMCloudInit -Node $Node -VMID $vm.VMID -Username $Username -Password $securePassword -SSHKey $sshKey -IPConfig $ipConfig -DNS $DNS
|
||||
Write-Log "Set Cloud-Init configuration for VM $($vm.VMID)"
|
||||
|
||||
# Start the VM if requested
|
||||
if ($StartVMs) {
|
||||
Write-Log "Starting VM $($vm.VMID)..."
|
||||
Start-ProxmoxVM -Node $Node -VMID $vm.VMID
|
||||
Write-Log "Started VM $($vm.VMID)"
|
||||
}
|
||||
|
||||
$vms += $vm
|
||||
}
|
||||
|
||||
# Display summary
|
||||
Write-Log "Summary:"
|
||||
Write-Log "Template: $($template.Name) (VMID: $($template.VMID))"
|
||||
Write-Log "VMs created:"
|
||||
$vms | ForEach-Object {
|
||||
Write-Log " - $($_.Name) (VMID: $($_.VMID))"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Log "Error: $_"
|
||||
}
|
||||
finally {
|
||||
# Disconnect from the Proxmox server
|
||||
if (Test-ProxmoxConnection) {
|
||||
Write-Log "Disconnecting from Proxmox server..."
|
||||
Disconnect-ProxmoxServer
|
||||
Write-Log "Disconnected from Proxmox server"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
# Create-CloudImageTemplate.ps1
|
||||
# This script demonstrates how to create a template from a cloud image and deploy VMs from it.
|
||||
|
||||
# Connect to the Proxmox server
|
||||
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
|
||||
Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam"
|
||||
|
||||
# Get available Ubuntu cloud images
|
||||
$ubuntuImages = Get-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04"
|
||||
Write-Host "Available Ubuntu 22.04 cloud images:"
|
||||
$ubuntuImages | Format-Table Distribution, Release, Variant, Format
|
||||
|
||||
# Download the Ubuntu 22.04 server cloud image
|
||||
$imagePath = Save-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server"
|
||||
Write-Host "Downloaded cloud image to: $imagePath"
|
||||
|
||||
# Customize the cloud image (resize to 20GB)
|
||||
$customizedImagePath = Invoke-ProxmoxCloudImageCustomization -ImagePath $imagePath -Resize 20
|
||||
Write-Host "Customized cloud image: $customizedImagePath"
|
||||
|
||||
# Create a template from the cloud image
|
||||
$template = New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04-template" -ImagePath $customizedImagePath -Storage "local-lvm" -Memory 2048 -Cores 2 -DiskSize 20
|
||||
Write-Host "Created template: $($template.Name) (VMID: $($template.VMID))"
|
||||
|
||||
# Create a VM from the template
|
||||
$vm = New-ProxmoxVMFromTemplate -Node "pve1" -TemplateName "ubuntu-22.04-template" -Name "web01"
|
||||
Write-Host "Created VM: $($vm.Name) (VMID: $($vm.VMID))"
|
||||
|
||||
# Set Cloud-Init configuration for the VM
|
||||
$sshKey = Get-Content -Path "~/.ssh/id_rsa.pub"
|
||||
$password = ConvertTo-SecureString "SecurePassword123!" -AsPlainText -Force
|
||||
Set-ProxmoxVMCloudInit -Node "pve1" -VMID $vm.VMID -Username "admin" -Password $password -SSHKey $sshKey -IPConfig "dhcp" -DNS "8.8.8.8,8.8.4.4"
|
||||
Write-Host "Set Cloud-Init configuration for VM $($vm.VMID)"
|
||||
|
||||
# Start the VM
|
||||
Start-ProxmoxVM -Node "pve1" -VMID $vm.VMID
|
||||
Write-Host "Started VM $($vm.VMID)"
|
||||
|
||||
# Create multiple VMs from the template
|
||||
$vms = New-ProxmoxVMFromTemplate -Node "pve1" -TemplateName "ubuntu-22.04-template" -Prefix "web" -Count 3 -Start
|
||||
Write-Host "Created multiple VMs:"
|
||||
$vms | Format-Table VMID, Name, Node, Status
|
||||
|
||||
# Disconnect from the Proxmox server
|
||||
Disconnect-ProxmoxServer
|
||||
Write-Host "Disconnected from Proxmox server"
|
||||
@@ -0,0 +1,33 @@
|
||||
# Simple-CloudImageTemplate.ps1
|
||||
# This script demonstrates the basic usage of cloud image template functionality.
|
||||
|
||||
# Connect to the Proxmox server
|
||||
Connect-ProxmoxServer -Server "proxmox.example.com" -Credential (Get-Credential)
|
||||
|
||||
# List available Ubuntu cloud images
|
||||
Get-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04"
|
||||
|
||||
# Download an Ubuntu 22.04 server cloud image
|
||||
$imagePath = Save-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server"
|
||||
Write-Host "Downloaded cloud image to: $imagePath"
|
||||
|
||||
# Create a template from the cloud image
|
||||
$template = New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04" -ImagePath $imagePath -Storage "local-lvm"
|
||||
Write-Host "Created template: $($template.Name) (VMID: $($template.VMID))"
|
||||
|
||||
# Create a VM from the template
|
||||
$vm = New-ProxmoxVMFromTemplate -Node "pve1" -TemplateName "ubuntu-22.04" -Name "web01"
|
||||
Write-Host "Created VM: $($vm.Name) (VMID: $($vm.VMID))"
|
||||
|
||||
# Set Cloud-Init configuration for the VM
|
||||
$password = ConvertTo-SecureString "SecurePassword123!" -AsPlainText -Force
|
||||
Set-ProxmoxVMCloudInit -Node "pve1" -VMID $vm.VMID -Username "admin" -Password $password -IPConfig "dhcp"
|
||||
Write-Host "Set Cloud-Init configuration for VM $($vm.VMID)"
|
||||
|
||||
# Start the VM
|
||||
Start-ProxmoxVM -Node "pve1" -VMID $vm.VMID
|
||||
Write-Host "Started VM $($vm.VMID)"
|
||||
|
||||
# Disconnect from the Proxmox server
|
||||
Disconnect-ProxmoxServer
|
||||
Write-Host "Disconnected from Proxmox server"
|
||||
@@ -0,0 +1,137 @@
|
||||
# Working with Cloud Image Templates
|
||||
|
||||
This guide explains how to work with cloud image templates in PSProxmox. Cloud images are pre-built, minimal operating system images designed for cloud environments. They typically come with Cloud-Init pre-installed, which allows for easy customization at boot time.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- PSProxmox module installed
|
||||
- Connection to a Proxmox VE server
|
||||
- QEMU tools installed on the system (for image customization)
|
||||
|
||||
## Finding Available Cloud Images
|
||||
|
||||
You can use the `Get-ProxmoxCloudImage` cmdlet to find available cloud images:
|
||||
|
||||
```powershell
|
||||
# Get all available cloud images
|
||||
Get-ProxmoxCloudImage
|
||||
|
||||
# Get Ubuntu cloud images
|
||||
Get-ProxmoxCloudImage -Distribution "ubuntu"
|
||||
|
||||
# Get Ubuntu 22.04 cloud images
|
||||
Get-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04"
|
||||
```
|
||||
|
||||
## Downloading Cloud Images
|
||||
|
||||
You can use the `Save-ProxmoxCloudImage` cmdlet to download cloud images:
|
||||
|
||||
```powershell
|
||||
# Download an Ubuntu 22.04 server cloud image
|
||||
$imagePath = Save-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server"
|
||||
|
||||
# Download a Debian 11 generic cloud image to a specific location
|
||||
$imagePath = Save-ProxmoxCloudImage -Distribution "debian" -Release "11" -Variant "generic" -OutputPath "C:\Images\debian-11.qcow2"
|
||||
```
|
||||
|
||||
## Customizing Cloud Images
|
||||
|
||||
You can use the `Invoke-ProxmoxCloudImageCustomization` cmdlet to customize cloud images:
|
||||
|
||||
```powershell
|
||||
# Resize a cloud image to 20GB
|
||||
$customizedImagePath = Invoke-ProxmoxCloudImageCustomization -ImagePath $imagePath -Resize 20
|
||||
|
||||
# Convert a cloud image to qcow2 format
|
||||
$customizedImagePath = Invoke-ProxmoxCloudImageCustomization -ImagePath $imagePath -ConvertTo "qcow2"
|
||||
|
||||
# Resize and convert a cloud image
|
||||
$customizedImagePath = Invoke-ProxmoxCloudImageCustomization -ImagePath $imagePath -Resize 20 -ConvertTo "qcow2" -OutputPath "C:\Images\ubuntu-22.04-custom.qcow2"
|
||||
```
|
||||
|
||||
## Creating Templates from Cloud Images
|
||||
|
||||
You can use the `New-ProxmoxCloudImageTemplate` cmdlet to create templates from cloud images:
|
||||
|
||||
```powershell
|
||||
# Create a template from an Ubuntu 22.04 cloud image
|
||||
$template = New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04" -Distribution "ubuntu" -Release "22.04" -Storage "local-lvm" -Memory 2048 -Cores 2 -DiskSize 20
|
||||
|
||||
# Create a template from a local cloud image file
|
||||
$template = 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
|
||||
```
|
||||
|
||||
## Setting Cloud-Init Configuration
|
||||
|
||||
You can use the `Set-ProxmoxVMCloudInit` cmdlet to set Cloud-Init configuration for a VM:
|
||||
|
||||
```powershell
|
||||
# Set Cloud-Init configuration for a VM
|
||||
$password = ConvertTo-SecureString "password" -AsPlainText -Force
|
||||
$sshKey = Get-Content -Path "~/.ssh/id_rsa.pub"
|
||||
Set-ProxmoxVMCloudInit -Node "pve1" -VMID 100 -Username "admin" -Password $password -SSHKey $sshKey -IPConfig "dhcp" -DNS "8.8.8.8,8.8.4.4"
|
||||
|
||||
# Set Cloud-Init configuration with static IP
|
||||
Set-ProxmoxVMCloudInit -Node "pve1" -VMID 100 -Username "admin" -Password $password -IPConfig "ip=192.168.1.100/24,gw=192.168.1.1"
|
||||
```
|
||||
|
||||
## Creating VMs from Templates
|
||||
|
||||
You can use the `New-ProxmoxVMFromTemplate` cmdlet to create VMs from templates:
|
||||
|
||||
```powershell
|
||||
# Create a VM from a template
|
||||
$vm = New-ProxmoxVMFromTemplate -Node "pve1" -TemplateName "ubuntu-22.04" -Name "web01"
|
||||
|
||||
# Create multiple VMs from a template
|
||||
$vms = New-ProxmoxVMFromTemplate -Node "pve1" -TemplateName "ubuntu-22.04" -Prefix "web" -Count 3 -Start
|
||||
```
|
||||
|
||||
## Complete Example
|
||||
|
||||
Here's a complete example that demonstrates the entire workflow:
|
||||
|
||||
```powershell
|
||||
# Connect to the Proxmox server
|
||||
$securePassword = ConvertTo-SecureString "password" -AsPlainText -Force
|
||||
Connect-ProxmoxServer -Server "proxmox.example.com" -Username "root" -Password $securePassword -Realm "pam"
|
||||
|
||||
# Download the Ubuntu 22.04 server cloud image
|
||||
$imagePath = Save-ProxmoxCloudImage -Distribution "ubuntu" -Release "22.04" -Variant "server"
|
||||
|
||||
# Customize the cloud image (resize to 20GB)
|
||||
$customizedImagePath = Invoke-ProxmoxCloudImageCustomization -ImagePath $imagePath -Resize 20
|
||||
|
||||
# Create a template from the cloud image
|
||||
$template = New-ProxmoxCloudImageTemplate -Node "pve1" -Name "ubuntu-22.04-template" -ImagePath $customizedImagePath -Storage "local-lvm" -Memory 2048 -Cores 2 -DiskSize 20
|
||||
|
||||
# Create a VM from the template
|
||||
$vm = New-ProxmoxVMFromTemplate -Node "pve1" -TemplateName "ubuntu-22.04-template" -Name "web01"
|
||||
|
||||
# Set Cloud-Init configuration for the VM
|
||||
$sshKey = Get-Content -Path "~/.ssh/id_rsa.pub"
|
||||
$password = ConvertTo-SecureString "SecurePassword123!" -AsPlainText -Force
|
||||
Set-ProxmoxVMCloudInit -Node "pve1" -VMID $vm.VMID -Username "admin" -Password $password -SSHKey $sshKey -IPConfig "dhcp" -DNS "8.8.8.8,8.8.4.4"
|
||||
|
||||
# Start the VM
|
||||
Start-ProxmoxVM -Node "pve1" -VMID $vm.VMID
|
||||
|
||||
# Disconnect from the Proxmox server
|
||||
Disconnect-ProxmoxServer
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use cloud images from official sources to ensure security and reliability.
|
||||
- Customize cloud images before creating templates to save time when deploying multiple VMs.
|
||||
- Use Cloud-Init to configure VMs at boot time instead of manually configuring each VM.
|
||||
- Use templates to ensure consistency across multiple VMs.
|
||||
- Use descriptive names for templates and VMs to make them easier to identify.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- If you encounter issues with cloud image downloads, check your internet connection and try again.
|
||||
- If you encounter issues with image customization, ensure that QEMU tools are installed on your system.
|
||||
- If you encounter issues with template creation, check the Proxmox VE server logs for more information.
|
||||
- If you encounter issues with Cloud-Init configuration, ensure that the VM has a Cloud-Init drive attached.
|
||||
Reference in New Issue
Block a user