テンプレート名
ACS-ECS-ScheduleToCleanUpDisks:ディスクのクリーンアップ
テンプレートの説明
このテンプレートは、ディスクのクリーンアップタスクをスケジュールします。このテンプレートは、自動ログファイルのクリーンアップや一時ファイルの削除など、Elastic Compute Service (ECS) インスタンスのディスク領域の定期的な管理とクリーンアップが必要なシナリオで役立ちます。このテンプレートを使用する際は、タイマートリガー (timerTrigger)、リージョン ID (regionId)、ターゲットインスタンス (targets)、およびクリーンアップルール (cleanUpInfos) を指定する必要があります。テンプレートの実行後、クリーンアップコマンドからの出力が返されます。この出力を使用して、ディスクのクリーンアップ操作のステータスを検証できます。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
timerTrigger | スケジュールされたタスクのタイプ。 | Json | はい | ||
targets | ターゲットインスタンス。 | Json | はい | ||
cleanUpInfos | ディスク内のデータのクリーンアップルール。 | String | はい | 文字列検証の正規表現:^["$`'\s]+$ | |
regionId | リージョン ID。 | String | いいえ | {{ ACS::RegionId }} | |
rateControl | タスク実行の同時実行数。 | Json | いいえ | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。 | String | いいえ | OOSServiceRole |
出力パラメーター
パラメーター | 説明 | タイプ |
commandOutputs | List |
テンプレートの実行に必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳細
詳細については、GitHub の ACS-ECS-ScheduleToCleanUpDisks.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: 'ディスクのクリーンアップタスクをスケジュールします。このテンプレートは、自動ログファイルのクリーンアップや一時ファイルの削除など、ECS インスタンスのディスク領域の定期的な管理とクリーンアップが必要なシナリオで役立ちます。設定時には、クリーンアップタスクの実行タイミングを定義するタイマートリガー (timerTrigger)、ターゲット ECS インスタンスのリージョンを指定するリージョン ID (regionId)、操作対象の特定の ECS インスタンスを定義するターゲットインスタンス (targets)、およびディスクのクリーンアップルールを指定するクリーンアップルール (cleanUpInfos) の必須パラメーターを指定する必要があります。実行後、テンプレートはクリーンアップコマンドからの出力リストを返します。これにより、ディスクのクリーンアップ操作のステータスを確認できます。'
zh-cn: Schedules disk cleanup tasks. This template is useful for scenarios that require periodic management and cleanup of disk space on ECS instances, such as automatic log file cleanup and temporary file deletion. During configuration, provide the following required parameters: a timer trigger (timerTrigger) to define when the cleanup task runs, a region ID (regionId) to specify the region of the target ECS instances, target instances (targets) to define the specific ECS instances to operate on, and cleanup rules (cleanUpInfos) to specify the disk cleanup rules. After execution, the template returns a list of output from the cleanup command. This lets you verify the status of the disk cleanup operations.
name-en: ディスクのクリーンアップ
name-zh-cn: Clean up disks
categories:
- time_trigger
- application_manage
- computenest
Parameters:
timerTrigger:
Type: Json
Label:
en: タイマートリガー
zh-cn: Timer trigger
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
regionId:
Type: String
Label:
en: リージョン ID
zh-cn: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: ターゲットインスタンス
zh-cn: Target instance
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
Status: Running
cleanUpInfos:
Description:
en: 'フォーマット:3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log。'
zh-cn: 'Format: 3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log'
Label:
en: クリーンアップルール
zh-cn: Cleanup rule
Type: String
AssociationProperty: ALIYUN::OOS::Component::CleanUpInfo
AllowedPattern: "^[^\"$`'\s]+$"
rateControl:
Label:
en: レート制御
zh-cn: Task execution concurrency rate
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: RAM role assumed by OOS
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: 'ACS::TimerTrigger'
Description:
en: 指定されたタイプと式に基づいてタスクをスケジュール通りにトリガーします。
zh-cn: Triggers the task based on the specified trigger type and expression.
Properties:
Type:
'Fn::Select':
- type
- '{{timerTrigger}}'
Expression:
'Fn::Select':
- expression
- '{{timerTrigger}}'
StartDate:
'Fn::Select':
- startDate
- '{{ timerTrigger }}'
EndDate:
'Fn::Select':
- endDate
- '{{ timerTrigger }}'
TimeZone:
'Fn::Select':
- timeZone
- '{{ timerTrigger }}'
- Name: getInstance
Description:
en: ECS インスタンスを表示します。
zh-cn: Gets the ECS instances.
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: cleanUpDisk
Action: 'ACS::ECS::CleanUpDisk'
Description:
en: クラウドアシスタントコマンドを実行してディスクをクリーンアップします。
zh-cn: Runs a Cloud Assistant command to clean up the disk.
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
cleanUpInfos: '{{ cleanUpInfos }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
Outputs:
commandOutputs:
Type: List
Value: '{{ cleanUpDisk.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- timerTrigger
Label:
default:
zh-cn: Cleanup time
en: クリーンアップ時間
- Parameters:
- cleanUpInfos
Label:
default:
zh-cn: Rule settings
en: ルール設定
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: Instance selection
en: インスタンスの選択
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Advanced options
en: 詳細オプション