运维编排创建个人模板提示“Error: Yaml 内容解析
创建个人模板时提示“Error: Yaml 内容解析失败, 请检查Yaml 格式是否正确!”。
YAML模板规范如下
模板结构
Description: "" # 可选,描述,可用于说明模板的用途,目的等。
Parameters: # 可选,参数,允许您在执行时再提供具体的参数值。
Tasks: # 必填,任务,模板最重要的组成部分,定义了具体的动作细节。每一个任务都是一个动作的具象化使用
1. 描述信息
可用于模板,节点,参数
Description:
en: 英文描述
zh-cn:中文描述
name-en: 英文名称
name-zh-cn: 中问名称
categories: 所属类别,数组
2. 参数
Parameters:
parameter-name-1: # 参数名,有效字符为[a-zA-Z0-9_-],不允许有空格。建议采用首字母小写的骆驼式风格,如instanceId。
Type: String # 可选,类型,支持List, Number, String, Boolean, Json。默认: String
Description: description # 可选,描述,描述参数的用途
PluginType: Input/Text/Select/Datetime/Time/Code/Instances/Number/Cron
Input - 普通文本框输入
Text - 文本域
Select - 下拉选择
Datetime - 日期时间选择
Time - 时间选择器
Code - 脚本编辑器
Instances - 实例选择
Number - 数值型输入
Cron - 时间表达式
Placeholder: #提示值
Required: #是否必填
ValidateReg: #正则校验
DefaultValue: default-value # 可选,默认值,参数的默认值
AllowedNames: # 可选,包含参数允许值标识的列表
- value1
- value2
AllowedValues: # 可选,包含参数允许值的列表
- value1
MinLength: 1 # 可选,参数值的最小长度(即参数值长度 = MinLength),适用于Input
MaxLength: 10 # 可选,参数值的最大长度(即参数值长度 = MaxLength),适用于Input
校验规则:
1) 参数名称存在且唯一,且命名必须符合 [a-zA-Z0-9_\-]+ 规范
2)Type 的 值 只 能 为 List, Number, String, Boolean, Json
3)PluginType:Instances 只能存在一个
4)PluginType 的值只能为 Input/Text/Select/Datetime/Time/Code/Instances/Number/Cron 5)PluginType 为 Select 时 AllowedValues不能为空
3. 任务
Tasks:
- Name: TaskName1 # 必填,任务名称,有效字符为[a-zA-Z0-9_-],即英文字母数字下划线中划线,长度限制200个字符。建议使用驼峰式命名,如StartInstance
Action: TaskType # 必填,任务类型(也叫动作),可选值有
runCommand - 脚本执行
runLocalScript - 执行本地脚本
startupInstance - 启动实例,OP接口
shutdownInstance - 停止实例,OP接口
restartInstance - 重启实例,OP接口
timingSwitchInstance - 定时开关机
installPackage - 软件安装
uninstallPackage - 软件卸载
Description: description # 可选,描述,描述当前任务的用途。
ExecuteType: timing #可选,标识该任务是定时类任务
Properties: # 根据所使用的动作不同,具体的属性列表不同,请参考动作相关的文档。
Property1: Value1 # 动作所依赖的属性和值
校验规则:
1) 任务名称存在且唯一,且命名必须符合 [a-zA-Z0-9_\-]+ 规范
2)Action 存在且值为
runCommand/runLocalScript/startupInstance/shutdownInstance/restartInstance/timingSwitchInstance/installPackage/unins
3)Action 固定参数校验
runCommand - uuid,cmdType,cmd
cmdType:脚本类型
cmd:脚本内容
runLocalScript - uuid,scriptPath
scriptPath:脚本路径
startupInstance - uuid
shutdownInstance - uuid
restartInstance - uuid
timingSwitchInstance - uuid,startupTime,shutdownTime,executeCycle
startupTime:启动时间
shutdownTime:关闭时间
executeCycle:执行周期
installPackage - uuid,softwareName
softwareName:软件名称
uninstallPackage - uuid,softwareName
softwareName:软件名称
其 中 uuid 都 为 执 行 实 例 的 UUID
4)Properties 中的变量名称必须在参数中定义
可用于说明模板的用途,目的等。Parameters: # 可选,参数,允许您在执行时再提供具体的参数值。Tasks: # 必填,任务,模板最重要的组成部分,定义了具体的动作细节。每一个任务都是一个动作的具象化使用