日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

創建模板

本文以批量在ECS實例中執行命令為例,介紹如何在系統運維管理 OOS(CloudOps Orchestration Service)控制臺新建自定義模板。

  1. 登錄系統運維管理控制臺

  2. 選擇自動化任務 > 自定義任務模板,單擊創建模板image

  3. 使用示例模板創建或使用本地文件創建。

    • 示例模板選擇批量執行命令,單擊下一步image

    • 如果您已經預先編寫好批量執行命令YAML或JSON格式的模板文件,您可以選擇使用本地文件創建,上傳后,單擊下一步image

      批量執行命令模板內容

      FormatVersion: OOS-2019-06-01
      Description: 批量在ECS實例中執行命令
      Parameters:
        targets:
          Label:
            en: TargetInstance
            zh-cn: 目標實例
          Type: Json
          AssociationProperty: Targets
          AssociationPropertyMetadata:
            ResourceType: ALIYUN::ECS::Instance
            RegionId: regionId
        rateControl:
          Label:
            en: RateControl
            zh-cn: 任務執行的并發比率
          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
      
              ##### 可在腳本開始運行時調用,打印當時的時間戳及PID。
              function job_start()
              {
                  now=`date +'%Y-%m-%d %H:%M:%S'`
                  echo "[$now][$$] job_start"
              }
      
              ##### 如果返回值為0,則認為此執行成功,如果非0,則認為執行失敗
              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",
              "zh-cn": "目標實例"
            },
            "Type": "Json",
            "AssociationProperty": "Targets",
            "AssociationPropertyMetadata": {
              "ResourceType": "ALIYUN::ECS::Instance",
              "RegionId": "regionId"
            }
          },
          "rateControl": {
            "Label": {
              "en": "RateControl",
              "zh-cn": "任務執行的并發比率"
            },
            "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##### 可在腳本開始運行時調用,打印當時的時間戳及PID。\nfunction job_start()\n{\n    now=`date +'%Y-%m-%d %H:%M:%S'`\n    echo \"[$now][$$] job_start\"\n}\n\n##### 如果返回值為0,則認為此執行成功,如果非0,則認為執行失敗\njob_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 }}"
          }
        }
      }
  4. (可選)獲取ECS實例已經預置,如需修改可以在模板參數-targets部分進行配置。

    說明

    選擇需要執行命令的 ECS 實例,在創建執行時填寫相關信息。詳情,請參見創建執行

    image

  5. 命令內容區域,編輯腳本內容,單擊創建模板

    image

  6. 填寫模板名稱,單擊完成創建image

相關文檔

  • 創建模板后,需為其創建并啟動執行,請參見創建執行

  • 如果您已充分了解模板中所有任務的風險,可選擇無需確認模式直接啟動執行,請參見全自動執行

  • 如果您想手動執行模板中的單個任務,可在創建執行時選擇單步模式,請參見單步執行