PackerBuild@1 - マシン イメージ v1 タスクをビルドする

このタスクを使用して、Packer を使用してマシン イメージを構築します。これは、Azure 仮想マシン スケール セットのデプロイに使用できます。

注意

このタスクでは、ワークフロー ID フェデレーションを使用した Azure Resource Manager認証はサポートされていません。

構文

# 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.

入力

templateType - Packer テンプレート
string. 必須です。 使用できる値: builtin (自動生成)、 custom (ユーザー指定)。 既定値: builtin

タスクで Packer テンプレートを自動生成するか、提供されたカスタム テンプレートを使用するかを指定します。


customTemplateLocation - Packer テンプレートの場所
string. templateType = custom の場合に必要です。

カスタム ユーザー指定テンプレートへのパスを指定します。


customTemplateParameters - テンプレート パラメーター
string. 省略可能。 の場合は templateType = customを使用します。 既定値: {}

カスタム テンプレートを構築するために Packer に渡されるパラメーターを指定します。 これにより、カスタム テンプレート内の variables セクションにマップされます。 たとえば、テンプレートに という名前 drop-locationの変数がある場合は、名前 drop-location と使用する値を含むパラメーターをここに追加します。 値をリリース変数にリンクすることもできます。 グリッド内の追加のパラメーターを表示または編集するには、テキスト ボックスの横にある を クリックします。


ConnectedServiceName - Azure サブスクリプション
string. templateType = builtin の場合に必要です。

マシン イメージをベイクして格納するための Azure Resource Manager サブスクリプションを指定します。


isManagedImage - マネージド VM ディスク イメージ
boolean. 省略可能。 の場合は templateType = builtinを使用します。 既定値: true

生成されたイメージがマネージド イメージである必要があるかどうかを確認します。


managedImageName - マネージド VM ディスク イメージ名
string. isManagedImage = true && templateType = builtin の場合に必要です。

自動生成されたテンプレートのマネージド ディスク イメージの名前を指定します。


location - 保存場所
string. templateType = builtin の場合に必要です。

ビルドされたマシン イメージを格納する場所を指定します。 この場所は、イメージを構築するために一時的な VM を作成するためにも使用されます。


storageAccountName - ストレージ アカウント
string. templateType = builtin の場合に必要です。

ビルドされたマシン イメージを格納するためのストレージ アカウントを指定します。 このストレージ アカウントは、選択した場所に事前に存在している必要があります。


azureResourceGroup - リソース グループ
string. templateType = builtin の場合に必要です。

選択したストレージ アカウントを含む Azure リソース グループを指定します。


baseImageSource - 基本イメージ ソース
string. templateType = builtin の場合に必要です。 使用できる値: default (ギャラリー)、 customVhd (カスタム)。 既定値: default

基本イメージのソースを指定します。 OS イメージのキュレーションされたギャラリーから選択するか、カスタム VHD イメージの URL を指定できます。

注意

オプションをオンにしてマネージド イメージを作成するオプションを Managed VM disk image 選択した場合は、ここでオプションのみを選択する Gallery 必要があります。 Custom source は、マネージド イメージの作成ではサポートされていません。


baseImage - 基本イメージ
string. baseImageSource = default && templateType = builtin の場合に必要です。 使用できる値: 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.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)。 既定値: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows

キュレーションされた OS イメージの一覧から選択します。 これは、マシン イメージをキャプチャする前に前提条件とアプリケーションをインストールするために使用されます。


baseImage - 基本イメージ
string. baseImageSource = default && templateType = builtin の場合に必要です。 使用できる値: 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)。 既定値: MicrosoftWindowsServer:WindowsServer:2012-R2-Datacenter:windows

キュレーションされた OS イメージの一覧から選択します。 これは、マシン イメージをキャプチャする前に前提条件とアプリケーションをインストールするために使用されます。


customImageUrl - 基本イメージの URL
string. baseImageSource = customVhd && templateType = builtin の場合に必要です。

基本イメージの URL を指定します。 これは、マシン イメージをキャプチャする前に前提条件とアプリケーションをインストールするために使用されます。


customImageOSType - 基本イメージ OS
string. baseImageSource = customVhd && templateType = builtin の場合に必要です。 使用できる値: windowslinux。 既定値: windows


packagePath - 展開パッケージ
string. templateType = builtin の場合に必要です。

への相対配置パッケージ ディレクトリのパスを $(System.DefaultWorkingDirectory)指定します。 ミニマッチ パターンをサポートします。 例のパス: FrontendWebApp/**/GalleryApp

Note

このパッケージは、Packer によって作成される一時的な仮想マシンにコピーされます。 パッケージに多数のファイルが含まれている場合や、ファイルのサイズが非常に大きい場合、アップロードに時間がかかる場合があります (数時間実行されている可能性があります)。 アップロード時間を最適化するには、パッケージのサイズを有意義に削減できるかどうかを確認してください。 もう 1 つの方法は、中間 Azure ストレージ アカウントを使用することです。 このタスクを実行する前に、パッケージをストレージ アカウントにアップロードします。 このタスクでは、必要なパッケージをストレージ アカウントからダウンロードするスクリプトを含むパッケージを使用します。


deployScriptPath - デプロイ スクリプト
string. templateType = builtin の場合に必要です。

パッケージをデプロイする powershell スクリプト (Windows の場合) またはシェル スクリプト (Linux の場合) への相対パスを指定します。 このスクリプトは、上記で選択したパッケージ パスに含まれている必要があります。 ミニマッチ パターンをサポートします。 パスの例: deploy/**/scripts/windows/deploy.ps1


deployScriptArguments - デプロイ スクリプトの引数
string. 省略可能。 の場合は templateType = builtinを使用します。

デプロイ スクリプトに渡す引数を指定します。


additionalBuilderParameters - 追加の Builder パラメーター
string. 省略可能。 の場合は templateType = builtinを使用します。 既定値: {"vm_size":"Standard_D3_v2"}

自動生成された Packer テンプレート モードでは、タスクによって Azure ビルダーを使用して Packer テンプレートが作成されます。 このビルダーは、マシン イメージの生成に使用されます。 Azure ビルダーにキーを追加して、生成された Packer テンプレートをカスタマイズできます。 例: CentOS 基本イメージを使用していて、 を実行sudoするために tty が必要な場合は、 を設定ssh_tty=trueします。 グリッド内の追加のパラメーターを表示または編集するには、テキスト ボックスの横にある を クリックします。


skipTempFileCleanupDuringVMDeprovision - プロビジョニング解除中に一時ファイルのクリーンアップをスキップする
boolean. 省略可能。 の場合は templateType = builtinを使用します。 既定値: true

VM のプロビジョニング解除中に、VM にアップロードされた一時ファイルのクリーンアップをスキップします。 Packer の Azure Virtual Machine Image Builders の詳細を確認してください。


packerVersion - Packer バージョン
string. 省略可能。 の場合は templateType = customを使用します。

インストールする Packer のバージョンを指定します。 これはカスタム テンプレートでのみ機能します。


imageUri - イメージの URL または名前
string.

非マネージド VM イメージの生成されたマシン イメージ VHD URL またはマネージド VM イメージのイメージ名を格納する出力変数の名前を指定します。


imageId - Azure リソース ID
string.

新しく作成されたイメージの Azure リソース ID を格納する出力変数の名前を指定します。 これはマネージド イメージ専用です。


タスク制御オプション

すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「 コントロール オプションと一般的なタスク プロパティ」を参照してください。

出力変数

[なし] :

解説

このタスクを使用して、Packer を使用してマシン イメージをビルドします。 このイメージは、Azure 仮想マシン スケール セットのデプロイに使用できます。

注意

詳細なログを有効にする場合は、[パイプライン] [変数>編集]> に移動し、新しい変数をPACKER_LOG追加し、その値を 1 に設定します。

必要条件

要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
上で実行 エージェント、DeploymentGroup
確認要求 なし
Capabilities このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 Any
設定可能な変数 Any
エージェントのバージョン 2.0.0 以上
タスクのカテゴリ 配置