Nom du modèle
ACS-ECS-ScheduleToCleanUpDisks : nettoie les disques
Description du modèle
Ce modèle planifie des tâches de nettoyage périodique des disques sur les instances Elastic Compute Service (ECS), telles que la suppression automatique des fichiers journaux et des fichiers temporaires. Spécifiez un déclencheur temporel (timerTrigger), un ID de région (regionId), les instances cibles (targets) et les règles de nettoyage (cleanUpInfos). Après l'exécution, le modèle renvoie la sortie de la commande de nettoyage, qui permet de vérifier l'état du nettoyage des disques.
Type de modèle
Automatisé
Propriétaire
Alibaba Cloud
Paramètres d'entrée
|
Paramètre |
Description |
Type |
Obligatoire |
Valeur par défaut |
Limite |
|
timerTrigger |
Configuration de planification de la tâche de nettoyage. |
Json |
Oui |
||
|
targets |
Instances ECS cibles. |
Json |
Oui |
||
|
cleanUpInfos |
Règles de nettoyage des disques. |
String |
Oui |
Expression régulière de validation de chaîne : ^["$`'\s]+$ |
|
|
regionId |
ID de la région. |
String |
Non |
{{ ACS::RegionId }} |
|
|
rateControl |
Niveau de concurrence d'exécution des tâches. |
Json |
Non |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} |
|
|
OOSAssumeRole |
Rôle RAM endossé par OOS. |
String |
Non |
OOSServiceRole |
Paramètres de sortie
|
Paramètre |
Description |
Type |
|
commandOutputs |
List |
Politique d'autorisation requise pour exécuter le modèle
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Détails
Pour plus d'informations, consultez le fichier ACS-ECS-ScheduleToCleanUpDisks.yml sur GitHub.
Contenu du modèle
FormatVersion: OOS-2019-06-01
Description:
en: '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.'
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: Clean up disks
name-zh-cn: Clean up disks
categories:
- time_trigger
- application_manage
- computenest
Parameters:
timerTrigger:
Type: Json
Label:
en: Timer trigger
zh-cn: Timer trigger
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
regionId:
Type: String
Label:
en: Region ID
zh-cn: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: Target instance
zh-cn: Target instance
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: 'Format: 3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log'
Label:
en: Cleanup rule
zh-cn: Cleanup rule
Type: String
AssociationProperty: ALIYUN::OOS::Component::CleanUpInfo
AllowedPattern: "^[^\"$`'\s]+$"
rateControl:
Label:
en: Rate control
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: Triggers a task as scheduled by specifying a type and expression.
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: Views the ECS instances.
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: Runs a Cloud Assistant command to clean up the disk.
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: Cleanup time
- Parameters:
- cleanUpInfos
Label:
default:
zh-cn: Rule settings
en: Rule settings
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: Instance selection
en: Instance selection
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Advanced options
en: Advanced options