mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 06:08:07 +00:00
committed by
GitHub
parent
d09a712b71
commit
8077d7b42b
@@ -12,8 +12,7 @@ If the VM deployment succeeds, Packer connects it using ssh or WinRM and begins
|
||||
If any step fails, image generation is aborted and the temporary VM is terminated.
|
||||
Packer also attempts to cleanup all the temporary resources it created (unless otherwise configured).
|
||||
|
||||
After successful completion of all installation steps Packer converts snapshot of the temporary VM to VHD image
|
||||
and uploads it to the specified Azure Storage Account.
|
||||
After successful completion of all installation steps Packer creates managed image from the temporary VM's disk and deletes the VM.
|
||||
|
||||
## Build agent preparation
|
||||
|
||||
@@ -147,31 +146,29 @@ Start-Sleep -Seconds 30
|
||||
|
||||
## Generated machine deployment
|
||||
|
||||
After the successful image generation, Virtual Machine can be created from the generated VHD using [CreateAzureVMFromPackerTemplate](../helpers/CreateAzureVMFromPackerTemplate.ps1) script.
|
||||
After the successful image generation, Virtual Machine can be created from the generated image using [CreateAzureVMFromPackerTemplate](../helpers/CreateAzureVMFromPackerTemplate.ps1) script.
|
||||
|
||||
```powershell
|
||||
Import-Module .\helpers\CreateAzureVMFromPackerTemplate.ps1
|
||||
|
||||
CreateAzureVMFromPackerTemplate -SubscriptionId {YourSubscriptionId} -ResourceGroupName {ResourceGroupName} -TemplateFile "C:\BuildVmImages\temporaryTemplate.json" -VirtualMachineName "testvm1" -AdminUsername "shady1" -AdminPassword "SomeSecurePassword1" -AzureLocation "eastus"
|
||||
CreateAzureVMFromPackerTemplate -SubscriptionId {YourSubscriptionId} -ResourceGroupName {ResourceGroupName} -ManagedImageName "Runner-Image-Ubuntu2204" -VirtualMachineName "testvm1" -AdminUsername "shady1" -AdminPassword "SomeSecurePassword1" -AzureLocation "eastus"
|
||||
```
|
||||
|
||||
Where:
|
||||
|
||||
- `SubscriptionId` - The Azure subscription Id where resources will be created.
|
||||
- `ResourceGroupName` - The Azure resource group name where the Azure virtual machine will be created.
|
||||
- `TemplateFilePath` - The path to the json ARM-template generated by packer during image generation locally.*
|
||||
- `ManagedImageName` - The name of the managed image to be used for the virtual machine creation.
|
||||
- `VirtualMachineName` - The name of the virtual machine to be generated.
|
||||
- `AdminUserName` - The administrator username for the virtual machine to be created.
|
||||
- `AdminPassword` - The administrator password for the virtual machine to be created.
|
||||
- `AzureLocation` - The location where the Azure virtual machine will be provisioned. Example: "eastus"
|
||||
|
||||
\* *ARM-template can be obtained from the Packer output. For now, it seems like there is an [Az CLI bug](https://github.com/Azure/azure-cli/issues/5899) with specifying the template through a URI, so download the template from URI, that will be printed at the bottom of image-generation log, and use the local path of the template file.*
|
||||
|
||||
The function creates an Azure VM from a template and generates network resources in Azure to make the VM accessible.
|
||||
The function creates an Azure VM and generates network resources in Azure to make the VM accessible.
|
||||
|
||||
## Manual image generation
|
||||
|
||||
If you want more control over image generation process you may run Packer directly. This section describes variables defined in Packer template. Some of them may be set using environment variabes.
|
||||
If you want more control over image generation process you may run Packer directly. This section describes variables defined in Packer template. Some of them may be set using environment variables.
|
||||
|
||||
### Required variables
|
||||
|
||||
@@ -182,11 +179,11 @@ If you want more control over image generation process you may run Packer direct
|
||||
| `client_secret` | `ARM_CLIENT_SECRET` | The password or secret for your service principal; may be omitted if `client_cert_path` is set.
|
||||
| `client_cert_path` | `ARM_CLIENT_CERT_PATH` | The location of a PEM file containing a certificate and private key for service principal; may be omitted if `client_secret` is set.
|
||||
| `location` | `ARM_RESOURCE_LOCATION` | Azure datacenter in which your VM will build.
|
||||
| `resource_group` | `ARM_RESOURCE_GROUP` | Resource group under which the final artifact will be stored.
|
||||
| `storage_account` | `ARM_STORAGE_ACCOUNT` | Storage account under which the final artifact will be stored.
|
||||
| `managed_image_resource_group_name` | `ARM_RESOURCE_GROUP` | Resource group under which the final artifact will be stored.
|
||||
|
||||
### Optional variables
|
||||
|
||||
- `managed_image_name` - Name of the managed image to create. If not specified, "Runner-Image-{{ImageType}}" will be used.
|
||||
- `build_resource_group_name` - Specify an existing resource group to run the build in it. By default, a temporary resource group will be created and destroyed as part of the build. If you do not have permission to do so, use build_resource_group_name to specify an existing resource group to run the build in it.
|
||||
- `object_id` - The object ID for the AAD SP. Will be derived from the oAuth token if empty.
|
||||
- `tenant_id` - The Active Directory tenant identifier with which your `client_id` and `subscription_id` are associated. If not specified, `tenant_id` will be looked up using `subscription_id`.
|
||||
@@ -195,13 +192,12 @@ If you want more control over image generation process you may run Packer direct
|
||||
- `virtual_network_name` - Use a pre-existing virtual network for the VM. This option enables private communication with the VM, no public IP address is used or provisioned (unless you set `private_virtual_network_with_public_ip`).
|
||||
- `virtual_network_resource_group_name` - If `virtual_network_name` is set, this value may also be set. If `virtual_network_name` is set, and this value is not set the builder attempts to determine the resource group containing the virtual network. If the resource group cannot be found, or it cannot be disambiguated, this value should be set.
|
||||
- `virtual_network_subnet_name` - If `virtual_network_name` is set, this value may also be set. If `virtual_network_name` is set, and this value is not set the builder attempts to determine the subnet to use with the virtual network. If the subnet cannot be found, or it cannot be disambiguated, this value should be set.
|
||||
- `capture_name_prefix` - VHD prefix. The final artifacts will be named PREFIX-osDisk.UUID and PREFIX-vmTemplate.UUID.
|
||||
|
||||
### Builder variables
|
||||
|
||||
The `builders` section contains variables for the `azure-arm` builder used in the project. Most of the builder variables are inherited from the `user variables` section, however, the variables can be overwritten to adjust image-generation performance.
|
||||
|
||||
- `vm_size` - Size of the VM used for building. This can be changed when you deploy a VM from your VHD.
|
||||
- `vm_size` - Size of the VM used for building. This can be changed when you deploy a VM from your image.
|
||||
- `image_os` - Type of OS that will be deployed as a temporary VM.
|
||||
- `image_version` - Specify version of an OS to boot from.
|
||||
|
||||
@@ -221,14 +217,14 @@ Generated tool versions and details can be found in related projects:
|
||||
|
||||
> :warning: These scripts are intended to run on a VM deployed in Azure
|
||||
|
||||
The user, created during the image generation, does not exist in the result VHD hence some configuration files related to the user's home directory need to be changed as well as the file permissions for some directories. Scripts for that are located in the `post-generation` folder in the repository:
|
||||
The user, created during the image generation, does not exist in the result image hence some configuration files related to the user's home directory need to be changed as well as the file permissions for some directories. Scripts for that are located in the `post-generation` folder in the repository:
|
||||
|
||||
- Windows: <https://github.com/actions/runner-images/tree/main/images/win/post-generation>
|
||||
- Linux: <https://github.com/actions/runner-images/tree/main/images/linux/post-generation>
|
||||
|
||||
**Note:** The default user for Linux should have `sudo privileges`.
|
||||
|
||||
The scripts are copied to the VHD during the image generation process to the following paths:
|
||||
The scripts are copied to the image during the generation process to the following paths:
|
||||
|
||||
- Windows: `C:\post-generation`
|
||||
- Linux: `/opt/post-generation`
|
||||
|
||||
Reference in New Issue
Block a user