Редактиране

Споделяне чрез


PackerBuild@1 - Build machine image v1 task

Use this task to build a machine image using Packer, which may be used for Azure Virtual machine scale set deployment.

Syntax

# Build machine image v1
# Build a machine image using Packer, which may be used for Azure Virtual machine scale set deployment.
- task: PackerBuild@1
  inputs:
    templateType: 'builtin' # 'builtin' | 'custom'. Required. Packer template. Default: builtin.
    #customTemplateLocation: # string. Required when templateType = custom. Packer template location. 
    #customTemplateParameters: '{}' # string. Optional. Use when templateType = custom. Template parameters. Default: {}.
  # Azure Details
    ConnectedServiceName: # string. Required when templateType = builtin. Azure subscription. 
    #isManagedImage: true # boolean. Optional. Use when templateType = builtin. Managed VM disk image. Default: true.
    #managedImageName: # string. Required when isManagedImage = true && templateType = builtin. Managed VM Disk Image Name. 
    location: # string. Required when templateType = builtin. Storage location. 
    storageAccountName: # string. Required when templateType = builtin. Storage account. 
    azureResourceGroup: # string. Required when templateType = builtin. Resource group. 
  # Deployment Inputs
    baseImageSource: 'default' # 'default' | 'customVhd'. Required when templateType = builtin. Base image source. Default: default.
    #baseImage: 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows' # 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows' | 'MicrosoftWindowsServer:WindowsServer:2016-Datacenter:windows' | 'MicrosoftWindowsServer:WindowsServer:2012-Datacenter:windows' | 'MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:windows' | 'Canonical:UbuntuServer:14.04.4-LTS:linux' | 'Canonical:UbuntuServer:16.04-LTS:linux' | 'Canonical:UbuntuServer:18.04-LTS:linux' | 'RedHat:RHEL:7.2:linux' | 'RedHat:RHEL:6.8:linux' | 'OpenLogic:CentOS:7.2:linux' | 'OpenLogic:CentOS:6.8:linux' | 'credativ:Debian:8:linux' | 'credativ:Debian:7:linux' | 'SUSE:openSUSE-Leap:42.2:linux' | 'SUSE:SLES:12-SP2:linux' | 'SUSE:SLES:11-SP4:linux'. Required when baseImageSource = default && templateType = builtin. Base image. Default: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows.
    #customImageUrl: # string. Required when baseImageSource = customVhd && templateType = builtin. Base image URL. 
    #customImageOSType: 'windows' # 'windows' | 'linux'. Required when baseImageSource = customVhd && templateType = builtin. Base image OS. Default: windows.
    packagePath: # string. Required when templateType = builtin. Deployment Package. 
    deployScriptPath: # string. Required when templateType = builtin. Deployment script. 
    #deployScriptArguments: # string. Optional. Use when templateType = builtin. Deployment script arguments. 
  # Advanced
    #additionalBuilderParameters: '{"vm_size":"Standard_D3_v2"}' # string. Optional. Use when templateType = builtin. Additional Builder parameters. Default: {"vm_size":"Standard_D3_v2"}.
    #skipTempFileCleanupDuringVMDeprovision: true # boolean. Optional. Use when templateType = builtin. Skip temporary file cleanup during deprovision. Default: true.
    #packerVersion: # string. Optional. Use when templateType = custom. Packer Version. 
  # Output
    #imageUri: # string. Image URL or Name. 
    #imageId: # string. Azure Resource Id.
# Build machine image v1
# Build a machine image using Packer, which may be used for Azure Virtual machine scale set deployment.
- task: PackerBuild@1
  inputs:
    templateType: 'builtin' # 'builtin' | 'custom'. Required. Packer template. Default: builtin.
    #customTemplateLocation: # string. Required when templateType = custom. Packer template location. 
    #customTemplateParameters: '{}' # string. Optional. Use when templateType = custom. Template parameters. Default: {}.
  # Azure Details
    ConnectedServiceName: # string. Required when templateType = builtin. Azure subscription. 
    #isManagedImage: true # boolean. Optional. Use when templateType = builtin. Managed VM disk image. Default: true.
    #managedImageName: # string. Required when isManagedImage = true && templateType = builtin. Managed VM Disk Image Name. 
    location: # string. Required when templateType = builtin. Storage location. 
    storageAccountName: # string. Required when templateType = builtin. Storage account. 
    azureResourceGroup: # string. Required when templateType = builtin. Resource group. 
  # Deployment Inputs
    baseImageSource: 'default' # 'default' | 'customVhd'. Required when templateType = builtin. Base image source. Default: default.
    #baseImage: 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows' # 'MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows' | 'MicrosoftWindowsServer:WindowsServer:2016-Datacenter:windows' | 'MicrosoftWindowsServer:WindowsServer:2012-Datacenter:windows' | 'MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:windows' | 'Canonical:UbuntuServer:14.04.4-LTS:linux' | 'Canonical:UbuntuServer:16.04-LTS:linux' | 'RedHat:RHEL:7.2:linux' | 'RedHat:RHEL:6.8:linux' | 'OpenLogic:CentOS:7.2:linux' | 'OpenLogic:CentOS:6.8:linux' | 'credativ:Debian:8:linux' | 'credativ:Debian:7:linux' | 'SUSE:openSUSE-Leap:42.2:linux' | 'SUSE:SLES:12-SP2:linux' | 'SUSE:SLES:11-SP4:linux'. Required when baseImageSource = default && templateType = builtin. Base image. Default: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows.
    #customImageUrl: # string. Required when baseImageSource = customVhd && templateType = builtin. Base image URL. 
    #customImageOSType: 'windows' # 'windows' | 'linux'. Required when baseImageSource = customVhd && templateType = builtin. Base image OS. Default: windows.
    packagePath: # string. Required when templateType = builtin. Deployment Package. 
    deployScriptPath: # string. Required when templateType = builtin. Deployment script. 
    #deployScriptArguments: # string. Optional. Use when templateType = builtin. Deployment script arguments. 
  # Advanced
    #additionalBuilderParameters: '{"vm_size":"Standard_D3_v2"}' # string. Optional. Use when templateType = builtin. Additional Builder parameters. Default: {"vm_size":"Standard_D3_v2"}.
    #skipTempFileCleanupDuringVMDeprovision: true # boolean. Optional. Use when templateType = builtin. Skip temporary file cleanup during deprovision. Default: true.
  # Output
    #imageUri: # string. Image URL or Name. 
    #imageId: # string. Azure Resource Id.

Inputs

templateType - Packer template
string. Required. Allowed values: builtin (Auto generated), custom (User provided). Default value: builtin.

Specifies whether the task auto generates a Packer template or uses a custom template provided by you.


customTemplateLocation - Packer template location
string. Required when templateType = custom.

Specifies the path to a custom user-provided template.


customTemplateParameters - Template parameters
string. Optional. Use when templateType = custom. Default value: {}.

Specifies the parameters which will be passed to the Packer for building a custom template. This should map to a variables section in your custom template. For example, if the template has a variable named drop-location, then add a parameter here with the name drop-location and a value which you want to use. You can link the value to a release variable as well. To view/edit the additional parameters in a grid, click on next to text box.


ConnectedServiceName - Azure subscription
string. Required when templateType = builtin.

Specifies the Azure Resource Manager subscription for baking and storing the machine image.


isManagedImage - Managed VM disk image
boolean. Optional. Use when templateType = builtin. Default value: true.

Checks if the generated image should be a managed image.


managedImageName - Managed VM Disk Image Name
string. Required when isManagedImage = true && templateType = builtin.

Specifies the name of the Managed disk image for auto-generated templates.


location - Storage location
string. Required when templateType = builtin.

Specifies the location for storing the built machine image. This location will also be used to create a temporary VM for the purpose of building an image.


storageAccountName - Storage account
string. Required when templateType = builtin.

Specifies the storage account for storing the built machine image. This storage account must be pre-existing in the location selected.


azureResourceGroup - Resource group
string. Required when templateType = builtin.

Specifies the Azure Resource group that contains the selected storage account.


baseImageSource - Base image source
string. Required when templateType = builtin. Allowed values: default (Gallery), customVhd (Custom). Default value: default.

Specifies the source of the base image. You can either choose from a curated gallery of OS images or provide a URL of your custom VHD image.

Note

If you have selected the option to create a Managed image by checking the Managed VM disk image option, then you should only choose the Gallery option here. Custom source is not supported to create a managed image.


baseImage - Base image
string. Required when baseImageSource = default && templateType = builtin. Allowed values: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows (Windows 2012-R2-Datacenter), MicrosoftWindowsServer:WindowsServer:2016-Datacenter:windows (Windows 2016-Datacenter), MicrosoftWindowsServer:WindowsServer:2012-Datacenter:windows (Windows 2012-Datacenter), MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:windows (Windows 2008-R2-SP1), Canonical:UbuntuServer:14.04.4-LTS:linux (Ubuntu 14.04.4-LTS), Canonical:UbuntuServer:16.04-LTS:linux (Ubuntu 16.04-LTS), Canonical:UbuntuServer:18.04-LTS:linux (Ubuntu 18.04-LTS), RedHat:RHEL:7.2:linux (RHEL 7.2), RedHat:RHEL:6.8:linux (RHEL 6.8), OpenLogic:CentOS:7.2:linux (CentOS 7.2), OpenLogic:CentOS:6.8:linux (CentOS 6.8), credativ:Debian:8:linux (Debian 8), credativ:Debian:7:linux (Debian 7), SUSE:openSUSE-Leap:42.2:linux (openSUSE-Leap 42.2), SUSE:SLES:12-SP2:linux (SLES 12-SP2), SUSE:SLES:11-SP4:linux (SLES 11-SP4). Default value: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows.

Chooses from a curated list of OS images. This will be used for installing pre-requisite(s) and application(s) before capturing a machine image.


baseImage - Base image
string. Required when baseImageSource = default && templateType = builtin. Allowed values: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows (Windows 2012-R2-Datacenter), MicrosoftWindowsServer:WindowsServer:2016-Datacenter:windows (Windows 2016-Datacenter), MicrosoftWindowsServer:WindowsServer:2012-Datacenter:windows (Windows 2012-Datacenter), MicrosoftWindowsServer:WindowsServer:2008-R2-SP1:windows (Windows 2008-R2-SP1), Canonical:UbuntuServer:14.04.4-LTS:linux (Ubuntu 14.04.4-LTS), Canonical:UbuntuServer:16.04-LTS:linux (Ubuntu 16.04-LTS), RedHat:RHEL:7.2:linux (RHEL 7.2), RedHat:RHEL:6.8:linux (RHEL 6.8), OpenLogic:CentOS:7.2:linux (CentOS 7.2), OpenLogic:CentOS:6.8:linux (CentOS 6.8), credativ:Debian:8:linux (Debian 8), credativ:Debian:7:linux (Debian 7), SUSE:openSUSE-Leap:42.2:linux (openSUSE-Leap 42.2), SUSE:SLES:12-SP2:linux (SLES 12-SP2), SUSE:SLES:11-SP4:linux (SLES 11-SP4). Default value: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows.

Chooses from a curated list of OS images. This will be used for installing pre-requisite(s) and application(s) before capturing a machine image.


customImageUrl - Base image URL
string. Required when baseImageSource = customVhd && templateType = builtin.

Specifies the URL of a base image. This will be used for installing pre-requisite(s) and application(s) before capturing a machine image.


customImageOSType - Base image OS
string. Required when baseImageSource = customVhd && templateType = builtin. Allowed values: windows, linux. Default value: windows.


packagePath - Deployment Package
string. Required when templateType = builtin.

Specifies the path for a deployment package directory relative to $(System.DefaultWorkingDirectory). Supports a minimatch pattern. Example path: FrontendWebApp/**/GalleryApp

Note

This package will be copied to a temporary virtual machine which Packer creates. If the package contains a large number of files and/or the files are very large in size, the upload can take a long time (possibly running for a few hours). To optimize the upload time, please see if the size of the package can be meaningfully reduced. Another alternative is to use an intermediary Azure storage account. Upload the package to a storage account prior to running this task. For this task, use a package containing a script which will download the required package from the storage account.


deployScriptPath - Deployment script
string. Required when templateType = builtin.

Specifies the relative path to the powershell script (for Windows) or the shell script (for Linux) which deploys the package. This script should be contained in the package path selected above. Supports a minimatch pattern. Example path: deploy/**/scripts/windows/deploy.ps1.


deployScriptArguments - Deployment script arguments
string. Optional. Use when templateType = builtin.

Specifies the arguments to be passed to the deployment script.


additionalBuilderParameters - Additional Builder parameters
string. Optional. Use when templateType = builtin. Default value: {"vm_size":"Standard_D3_v2"}.

In the auto-generated Packer template mode, the task creates a Packer template with an Azure builder. This builder is used to generate a machine image. You can add keys to the Azure builder to customize the generated Packer template. For example: Setting ssh_tty=true if you are using a CentOS base image and you need to have a tty to run sudo. To view/edit the additional parameters in a grid, click on next to text box.


skipTempFileCleanupDuringVMDeprovision - Skip temporary file cleanup during deprovision
boolean. Optional. Use when templateType = builtin. Default value: true.

During the deprovisioning of a VM, skips the cleanup of temporary files uploaded to the VM. Learn more about Azure Virtual Machine Image Builders in Packer.


packerVersion - Packer Version
string. Optional. Use when templateType = custom.

Specifies the version of Packer to install. This will work only with custom templates.


imageUri - Image URL or Name
string.

Specifies a name for the output variable which will store the generated machine image VHD URL for an un-managed VM image or the image name for a managed VM image.


imageId - Azure Resource Id
string.

Specifies a name for the output variable which will store the Azure Resource ID for the newly created image. This is for managed images only.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Use this task to build a machine image using Packer. This image can be used for Azure Virtual machine scale set deployment.

Note

If you want to enable detailed logs, navigate to Pipelines > Edit > Variables, and then add a new variable PACKER_LOG and set its value to 1.

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.0.0 or greater
Task category Deploy