3.2.2. 自動生成されたテンプレートの例
以下の例は、セルフサービス自動化ポータルが既存の Ansible Automation Platform ジョブテンプレートから自動生成するテンプレートを示しています。生成された YAML 内のすべてのフィールドは、Ansible Automation Platform のアーティファクトに直接マッピングされます。
-
Ansible Automation Platform のジョブテンプレートの名前と説明は、
メタデータフィールドになります。 -
各 起動時にプロンプトを表示する オプションは、
AAPResourcePicker のフィールドになります。 - Ansible Automation Platform Survey の各質問は、標準フォームフィールドになります。
-
ステップセクションでは、rhaap:launch-job-templateアクションを使用して、元の Ansible Automation Platform ジョブテンプレートを起動します。
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
# Namespace is hardcoded to "default"
namespace: default
# AAP artifact: Job Template name lowercase with hyphens
name: deploy-application
# AAP artifact: Job Template name title (copied directly)
title: Deploy Application
# AAP artifact: Job Template description description (copied directly)
description: Deploy application to target environment
# AAP artifact: Job Template labels tags (lowercase)
tags:
- automation
- aap
# AAP artifact: Job Template URL annotations
annotations:
backstage.io/techdocs-ref: url:https://aap.example.com/#/templates/job_template/42
backstage.io/source-location: url:https://aap.example.com/#/templates/job_template/42
spec:
type: service
parameters:
- title: "Please enter the following details"
required:
- token
- inventory
- app_name
properties:
# Always present: OAuth token for AAP authentication (hidden from user)
token:
title: Token
type: string
description: Oauth2 token
ui:field: AAPTokenField
ui:widget: hidden
ui:backstage:
review:
show: false
ui:options:
disabled: true
hidden: true
# AAP artifact: "Prompt on Launch" Inventory (users select by name; self-service portal resolves to AAP ID)
inventory:
title: Inventory
description: Please enter the inventory you want to use the services on
resource: inventories
ui:field: AAPResourcePicker
default: Production Servers
# AAP artifact: Survey question "Application Name" (variable, title, type, default from survey spec)
app_name:
title: Application Name
description: Name of the application to deploy
type: string
default: my-app
steps:
- id: launch-job
# AAP artifact: Job Template name used as the step name
name: Deploy Application
action: rhaap:launch-job-template
input:
token: ${{ parameters.token }}
values:
# AAP artifact: Job Template name identifies which template to launch
template: Deploy Application
# "Prompt on Launch" values passed as launch parameters
inventory: ${{ parameters.inventory }}
# Survey answers passed as extra variables to AAP
extraVariables:
app_name: ${{ parameters.app_name }}
output:
text:
- title: Deploy Application template executed successfully
content: |
**Job ID:** ${{ steps['launch-job'].output.data.id }}
**Job status:** ${{ steps['launch-job'].output.data.status }}
以下の表は、生成された各フィールドを対応する Ansible Automation Platform ソースにマッピングしたものです。
| Ansible Automation Platform ソース | Ansible Automation Platform の価値 | 生成されたフィールド | 変換 |
|---|---|---|---|
| 該当なし |
|
|
|
|
ジョブテンプレート | アプリケーションのデプロイ |
| ハイフン付きの小文字。 |
|
ジョブテンプレート | アプリケーションのデプロイ |
| そのままコピーしました。 |
|
求人テンプレート | アプリケーションをターゲット環境にデプロイします。 |
| そのままコピーしました。 |
|
求人テンプレート |
|
| 小文字、特殊文字はハイフンに置き換えられます。 |
| 常に存在する | OAuth2 トークン |
| 自動入力され、ユーザーには非表示になっています。 |
|
起動時のプロンプト | プロダクションサーバー |
|
|
|
アンケート | app_name (テキスト、必須、デフォルト値:my- アプリケーション) |
| 変数、タイトル、タイプ、およびデフォルト値は、Survey 仕様からコピーされました。 |
|
ジョブテンプレート | アプリケーションのデプロイ |
| 起動する Ansible Automation Platform ジョブテンプレートを指定します。 |
| 発売時の値 |
|
| 起動時に、名前が Ansible Automation Platform ID に解決されます。 |
| アンケート回答 |
|
|
|