模板名称
ACS-ECS-ScheduleToCleanUpDisks 清理磁盘
模板描述
定时清理磁盘,适用于需要定期管理和清理ECS实例中的磁盘空间的场景,例如日志文件的自动清理和临时文件的删除。在配置过程中,用户需要提供以下必填参数信息:定时类型(timerTrigger):用于定义清理任务何时触发,地域ID(regionId):用于指定需要清理磁盘的ECS实例所在的区域,目标实例(targets):用于定义具体需要操作的ECS实例,清理规则(cleanUpInfos):用于指定具体的磁盘清理规则。模板在执行后会返回清理命令的输出结果列表,方便用户验证磁盘清理操作的状态。
模板类型
自动化
所有者
Alibaba Cloud
输入参数
参数名称 | 描述 | 类型 | 是否必填 | 默认值 | 约束 |
timerTrigger | 定时类型 | Json | 是 | ||
targets | 目标实例 | Json | 是 | ||
cleanUpInfos | 磁盘清理规则 | String | 是 | 字符串校验正则表达式 :["‘′\s]+ | | |
regionId | 地域ID | String | 否 | {{ ACS::RegionId }} | |
rateControl | 任务执行的并发比率 | Json | 否 | {‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 10} | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | OOSServiceRole |
输出参数
参数名称 | 描述 | 类型 |
commandOutputs | List |
执行此模板需要的权限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
详情
ACS-ECS-ScheduleToCleanUpDisks详情
模板内容
FormatVersion: OOS-2019-06-01
Description:
en: 'Schedule to clean up disks, applicable to scenarios that require periodic management and cleaning of disk space on ECS instances, such as automatic log file cleanup and deletion of temporary files. During configuration, users need to provide the following required parameter information: Timer Trigger (timerTrigger), which defines when the cleanup task is triggered, Region ID (regionId), which specifies the region of the ECS instances where the disks will be cleaned, Target Instances (targets), which defines the specific ECS instances to be operated on, and Cleanup Rule (cleanUpInfos), which specifies the specific disk cleanup rules. Upon execution, the template will return a list of the output results of the cleanup command, enabling users to verify the status of the disk cleanup operations.'
zh-cn: 定时清理磁盘,适用于需要定期管理和清理ECS实例中的磁盘空间的场景,例如日志文件的自动清理和临时文件的删除。在配置过程中,用户需要提供以下必填参数信息:定时类型(timerTrigger):用于定义清理任务何时触发,地域ID(regionId):用于指定需要清理磁盘的ECS实例所在的区域,目标实例(targets):用于定义具体需要操作的ECS实例,清理规则(cleanUpInfos):用于指定具体的磁盘清理规则。模板在执行后会返回清理命令的输出结果列表,方便用户验证磁盘清理操作的状态。
name-en: Cleanup Disks
name-zh-cn: 清理磁盘
categories:
- time_trigger
- application_manage
- computenest
Parameters:
timerTrigger:
Type: Json
Label:
en: TimerTrigger
zh-cn: 定时类型
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: 目标实例
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
Status: Running
cleanUpInfos:
Description:
en: 'Format: 3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log.'
zh-cn: '格式:3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log'
Label:
en: CleanUpRule
zh-cn: 磁盘清理规则
Type: String
AssociationProperty: ALIYUN::OOS::Component::CleanUpInfo
AllowedPattern: "^[^\"$`'\\s]+$"
rateControl:
Label:
en: RateControl
zh-cn: 任务执行的并发比率
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: 'ACS::TimerTrigger'
Description:
en: Triggers a task as scheduled by specifying type and expression
zh-cn: 通过指定触发类型和表达式按计划触发任务
Properties:
Type:
'Fn::Select':
- type
- '{{timerTrigger}}'
Expression:
'Fn::Select':
- expression
- '{{timerTrigger}}'
EndDate:
'Fn::Select':
- endDate
- '{{ timerTrigger }}'
TimeZone:
'Fn::Select':
- timeZone
- '{{ timerTrigger }}'
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: 获取ECS实例
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: Execute cloud assistant command to clean up disk
zh-cn: 执行云助手命令清理磁盘
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: 清理时间
en: The time of cleanup disk
- Parameters:
- cleanUpInfos
Label:
default:
zh-cn: 设置规则
en: The rule of cleanup disk
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: 选择实例
en: Select ECS Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: 高级选项
en: Control Options
文档内容是否对您有帮助?