すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:テンプレートの作成

最終更新日:Jan 17, 2025

このトピックでは、CloudOps Orchestration Service (OOS) コンソールでカスタムテンプレートを作成する方法について説明します。このトピックでは、ACS-OOS-ExampleBulkyExecuteCommandsInEcs テンプレートに基づいてカスタムテンプレートが作成されます。CloudOps Orchestration Service (OOS)

  1. CloudOps Orchestration Service コンソール にログオンします。

  2. 左側のナビゲーションウィンドウで、[自動タスク] > [カスタムテンプレート] を選択します。 [カスタムテンプレート] ページで、[テンプレートの作成] をクリックします。image

  3. サンプルテンプレートまたはローカルファイルを使用して、テンプレートを作成します。

    • O&M テンプレート パラメーターに [acs-oos-examplebulkyexecutecommandsinecs] を選択し、[次のステップ] をクリックします。image

    • 複数の Elastic Compute Service (ECS) インスタンスで同時にコマンドを実行するために使用される .yaml または .json テンプレートファイルを作成した場合は、[ローカルファイルで作成] を選択し、テンプレートファイルをアップロードします。テンプレートファイルをアップロードした後、[次のステップ] をクリックします。image

      テンプレートファイルの内容

      FormatVersion: OOS-2019-06-01
      Description: 複数の ECS インスタンスで同時にコマンドを実行します。
      Parameters:
        targets:
          Label:
            en: TargetInstance
             
          Type: Json
          AssociationProperty: Targets
          AssociationPropertyMetadata:
            ResourceType: ALIYUN::ECS::Instance
            RegionId: regionId
        rateControl:
          Label:
            en: RateControl
             
          Type: Json
          AssociationProperty: RateControl
          Default:
            Mode: Concurrency
            MaxErrors: 0
            Concurrency: 10
      Tasks:
        - Name: getInstance
          Description: ECS インスタンスを取得します。
          Action: ACS::SelectTargets
          Properties:
            ResourceType: ALIYUN::ECS::Instance
            Filters:
              - '{{ targets }}'
          Outputs:
            instanceIds:
              Type: List
              ValueSelector: Instances.Instance[].InstanceId
        - Name: runCommand
          Action: ACS::ECS::RunCommand
          Description: クラウドアシスタントコマンドを実行します。
          Properties:
            instanceId: '{{ ACS::TaskLoopItem }}'
            commandType: RunShellScript
            commandContent: |-
              #!/bin/bash
      
               
              function job_start()
              {
                  now=`date +'%Y-%m-%d %H:%M:%S'`
                  echo "[$now][$$] job_start"
              }
      
               
              job_start
            regionId: '{{ ACS::RegionId }}'
            workingDir: /root
            enableParameter: false
            timeout: 600
            username: ''
            parameters: {}
            windowsPasswordName: ''
          Outputs:
            invocationOutput:
              Type: String
              ValueSelector: invocationOutput
          Loop:
            Items: '{{ getInstance.instanceIds }}'
            RateControl: '{{ rateControl }}'
            Outputs:
              invocationOutputs:
                AggregateType: Fn::ListJoin
                AggregateField: invocationOutput
      Outputs:
        invocationOutputs:
          Type: List
          Value: '{{ runCommand.invocationOutputs }}'
      
      {
        "FormatVersion": "OOS-2019-06-01",
        "Description": "複数の ECS インスタンスで同時にコマンドを実行します",
        "Parameters": {
          "targets": {
            "Label": {
              "en": "TargetInstance",
               
            },
            "Type": "Json",
            "AssociationProperty": "Targets",
            "AssociationPropertyMetadata": {
              "ResourceType": "ALIYUN::ECS::Instance",
              "RegionId": "regionId"
            }
          },
          "rateControl": {
            "Label": {
              "en": "RateControl",
               
            },
            "Type": "Json",
            "AssociationProperty": "RateControl",
            "Default": {
              "Mode": "Concurrency",
              "MaxErrors": 0,
              "Concurrency": 10
            }
          }
        },
        "Tasks": [
          {
            "Name": "getInstance",
            "Description": "ECS インスタンスを取得します",
            "Action": "ACS::SelectTargets",
            "Properties": {
              "ResourceType": "ALIYUN::ECS::Instance",
              "Filters": [
                "{{ targets }}"
              ]
            },
            "Outputs": {
              "instanceIds": {
                "Type": "List",
                "ValueSelector": "Instances.Instance[].InstanceId"
              }
            }
          },
          {
            "Name": "runCommand",
            "Action": "ACS::ECS::RunCommand",
            "Description": "クラウドアシスタントコマンドを実行します",
            "Properties": {
              "instanceId": "{{ ACS::TaskLoopItem }}",
              "commandType": "RunShellScript",
              "commandContent": "#!/bin/bash\n\n \nfunction job_start()\n{\n    now=`date +'%Y-%m-%d %H:%M:%S'`\n    echo \"[$now][$$] job_start\"\n}\n\n ",
              "regionId": "{{ ACS::RegionId }}",
              "workingDir": "/root",
              "enableParameter": false,
              "timeout": 600,
              "username": "",
              "parameters": {},
              "windowsPasswordName": ""
            },
            "Outputs": {
              "invocationOutput": {
                "Type": "String",
                "ValueSelector": "invocationOutput"
              }
            },
            "Loop": {
              "Items": "{{ getInstance.instanceIds }}",
              "RateControl": "{{ rateControl }}",
              "Outputs": {
                "invocationOutputs": {
                  "AggregateType": "Fn::ListJoin",
                  "AggregateField": "invocationOutput"
                }
              }
            }
          }
        ],
        "Outputs": {
          "invocationOutputs": {
            "Type": "List",
            "Value": "{{ runCommand.invocationOutputs }}"
          }
        }
      }
  4. オプション。 [getinstance] タスクステップの設定はプリセットされています。設定を変更する場合は、[テンプレートパラメーター] セクションの [targets] をクリックします。

    説明

    コマンドを実行する ECS インスタンスを選択し、実行の作成時にインスタンス情報を構成します。 詳細については、「実行の作成」をご参照ください。

  5. [プロセス設定] タブで、コードエディタに [コマンドの内容] を入力し、[テンプレートの作成] をクリックします。

    image

  6. [テンプレートの基本情報] ダイアログボックスで、[テンプレート名] パラメーターを設定し、[OK] をクリックします。image

参照

  • テンプレートを作成した後、テンプレートに基づいて実行を作成し、実行を開始できます。 詳細については、「実行の作成」をご参照ください。

  • テンプレート内のすべてのタスクのリスクを理解している場合は、実行の作成時に [実行モード] パラメーターを [自動] に設定できます。 詳細については、「自動実行」をご参照ください。

  • 実行を手動で開始する場合は、実行の作成時に [実行モード] パラメーターを [手動] に設定できます。 詳細については、「手動実行」をご参照ください。