Introduction:
As a PowerShell enthusiast, I was thrilled to learn about the ImageBuilder module, which allows us to create custom images for VMware without relying on the legacy PowerCLI. However, I soon realized that ImageBuilder is not yet core-compatible and requires a legacy PowerShell environment (-v5.1) with a Windows environment. This poses a challenge for home lab users who do not have access to a Windows environment. In this blog post, I will explore how we can use Github Actions to create custom images for VMware without relying on the legacy PowerCLI.
Background:
As we all know, creating custom images for VMware requires a lot of manual work, including downloading the VMware tools, creating a new image, and then uploading it to our desired location. This process can be time-consuming and error-prone, especially for those of us who do not have a Windows environment available.
Solution:
Github Actions provide a simple solution to automate the creation of custom images for VMware. By using the ImageBuilder module in conjunction with Github Actions, we can create custom images without relying on the legacy PowerCLI. The process is relatively straightforward:
1. First, we need to install the ImageBuilder module using the following command:
“`powershell
Install-Module -Name VMware.ImageBuilder -SourceLocation https://vmware.github.io/imagebuilder/powershell
“`
2. Next, we need to create a new Github Actions workflow file (e.g., `.github/workflows/image-builder.yml`) with the following content:
“`yaml
name: Image Builder Workflow
on: push
jobs:
build-image:
runs-on: windows-2019
steps:
– name: Checkout code
uses: actions/checkout@v2
– name: Install ImageBuilder
run: |
Install-Module -Name VMware.ImageBuilder -SourceLocation https://vmware.github.io/imagebuilder/powershell
– name: Build image
run: |
New-IsoImage -Path “C:\temp\image.iso” -Name “My Custom Image” -Description “My custom image” -Vendor VMware
“`
3. Save the workflow file and commit it to our Github repository.
4. Trigger the workflow by pushing a new commit to our repository.
5. Once the workflow completes, we will have a new, custom image available for use in VMware.
Benefits:
The benefits of using Github Actions to create custom images for VMware are numerous:
1. No need for a Windows environment: With Github Actions, we can create custom images without relying on a Windows environment. This makes it much easier for home lab users to create and use custom images.
2. Faster creation time: Using ImageBuilder in conjunction with Github Actions significantly speeds up the creation of custom images. This is because ImageBuilder uses a more modern and efficient approach to creating images, rather than relying on the legacy PowerCLI.
3. Improved reliability: By automating the image creation process, we can reduce the risk of errors and inconsistencies in our custom images.
4. Publicly available repository: Our custom image will be publicly available in our Github repository, making it easy to share and collaborate with others.
Conclusion:
In conclusion, Github Actions provide a simple and efficient solution for creating custom images for VMware without relying on the legacy PowerCLI. By using ImageBuilder in conjunction with Github Actions, we can automate the image creation process, reducing the need for a Windows environment and improving the speed and reliability of our custom images. This solution is perfect for home lab users who want to create and use custom images without the hassle of manual workarounds.