diff --git a/list-templates.json b/list-templates.json index 6e3375b..0f704d3 100644 --- a/list-templates.json +++ b/list-templates.json @@ -27,7 +27,7 @@ "CreatedDate": "2020-06-04T11:30:03Z", "Description": "{\"en\": \"Bulky upload files to instances\", \"zh-cn\": \"批量上传文件到多个ECS实例\", \"name-en\": \"Upload File\", \"name-zh-cn\": \"上传文件\", \"categories\": [\"instance_manage\", \"application_manage\", \"computenest\", \"tag_operate_resource\"]}", "HasTrigger": false, - "Hash": "fc2ed8350a34957400145f1868cf1e60260d0390aff85e8680c9db262cd4f902", + "Hash": "c5f013ed6e959ff07d2216e51f0743bc8588e0e1e8838ab2a79a9eba04b373d5", "IsFavorite": false, "Popularity": 9.99, "ResourceGroupId": "rg-acfmz4wrjukykdy", @@ -37,10 +37,10 @@ "TemplateId": "t-f3894c68400546069dfd", "TemplateName": "ACS-ECS-BulkyDownloadFile", "TemplateType": "Automation", - "TemplateVersion": "v25", + "TemplateVersion": "v26", "TotalExecutionCount": -1, "UpdatedBy": "ACS", - "UpdatedDate": "2024-07-30T02:46:43Z" + "UpdatedDate": "2024-11-19T09:11:38Z" }, { "Category": "Other", @@ -300,7 +300,7 @@ "CreatedDate": "2019-10-22T08:17:08Z", "Description": "{\"en\": \"Creates an ECS image\", \"zh-cn\": \"创建一个ECS镜像\", \"name-en\": \"Create Image\", \"name-zh-cn\": \"创建镜像\", \"categories\": [\"image_manage\", \"application_manage\"]}", "HasTrigger": false, - "Hash": "fed933ef370a7cb5fc17b7b2ad29c44495df86460978b5bc9991c1df67c064f1", + "Hash": "a4cbd44050049878432a9ee80599197fcee326af4c9db3f7c9311df7fa77d824", "IsFavorite": false, "Popularity": 8.23, "ResourceGroupId": "rg-acfmz4wrjukykdy", @@ -310,10 +310,10 @@ "TemplateId": "t-4bdb1745c171401883a2", "TemplateName": "ACS-ECS-CreateImage", "TemplateType": "Automation", - "TemplateVersion": "v19", + "TemplateVersion": "v20", "TotalExecutionCount": -1, "UpdatedBy": "ACS", - "UpdatedDate": "2024-09-14T08:12:12Z" + "UpdatedDate": "2024-11-19T03:19:05Z" }, { "Category": "Other", @@ -1833,7 +1833,7 @@ "CreatedDate": "2020-07-09T09:04:56Z", "Description": "{\"en\": \"Bulky modify instance charge type\", \"zh-cn\": \"批量修改实例的计费方式\", \"name-en\": \"ACS-ECS-BulkyModifyInstanceChargeType\", \"name-zh-cn\": \"批量修改实例的计费方式\", \"categories\": [\"instance_manage\"]}", "HasTrigger": false, - "Hash": "fc75d96ee8262a0926e9c534b70989f547c15323d8646a775c8b49c6cb456dc6", + "Hash": "2c5a9697fa78ac235dca9ab8763da1a476d8d4c3e4def1459b177fdaccf806a2", "IsFavorite": false, "Popularity": 5, "ResourceGroupId": "rg-acfmz4wrjukykdy", @@ -1843,10 +1843,10 @@ "TemplateId": "t-e4f861b5d66447158e56", "TemplateName": "ACS-ECS-BulkyModifyInstanceChargeType", "TemplateType": "Automation", - "TemplateVersion": "v18", + "TemplateVersion": "v19", "TotalExecutionCount": -1, "UpdatedBy": "ACS", - "UpdatedDate": "2024-02-22T03:18:12Z" + "UpdatedDate": "2024-11-19T07:22:14Z" }, { "Category": "Other", @@ -5334,6 +5334,27 @@ "UpdatedBy": "ACS", "UpdatedDate": "2024-10-17T06:01:58Z" }, + { + "Category": "Other", + "CreatedBy": "ACS", + "CreatedDate": "2024-09-02T03:38:03Z", + "Description": "{\"en\": \"Build and deploy applications on a single ECS\", \"zh-cn\": \"在单个ECS上构建并部署应用\", \"name-en\": \"ACS-ECS-LocalBuildAndDeployOnSingleECS\", \"name-zh-cn\": \"单ECS本地构建部署\"}", + "HasTrigger": false, + "Hash": "7700594d40b28f7d9e49144fc57304aff612365d887250ad107238ca833c83fb", + "IsFavorite": false, + "Popularity": 5, + "ResourceGroupId": "", + "ShareType": "Public", + "Tags": {}, + "TemplateFormat": "YAML", + "TemplateId": "t-19a26faf087d4d8a8a1a", + "TemplateName": "ACS-ECS-LocalBuildAndDeployOnSingleECS", + "TemplateType": "Automation", + "TemplateVersion": "v10", + "TotalExecutionCount": -1, + "UpdatedBy": "ACS", + "UpdatedDate": "2024-11-22T07:39:13Z" + }, { "Category": "Other", "CreatedBy": "ACS", @@ -6027,27 +6048,6 @@ "UpdatedBy": "ACS", "UpdatedDate": "2024-11-05T02:10:30Z" }, - { - "Category": "Other", - "CreatedBy": "ACS", - "CreatedDate": "2024-09-02T03:38:03Z", - "Description": "{\"en\": \"Build and deploy applications on a single ECS\", \"zh-cn\": \"在单个ECS上构建并部署应用\", \"name-en\": \"ACS-ECS-LocalBuildAndDeployOnSingleECS\", \"name-zh-cn\": \"单ECS本地构建部署\"}", - "HasTrigger": false, - "Hash": "4c299c207023ae5eb7f07298bbbf7e318d591a2ddcfeb36854c592b86bfe2766", - "IsFavorite": false, - "Popularity": 0, - "ResourceGroupId": "", - "ShareType": "Public", - "Tags": {}, - "TemplateFormat": "YAML", - "TemplateId": "t-19a26faf087d4d8a8a1a", - "TemplateName": "ACS-ECS-LocalBuildAndDeployOnSingleECS", - "TemplateType": "Automation", - "TemplateVersion": "v9", - "TotalExecutionCount": -1, - "UpdatedBy": "ACS", - "UpdatedDate": "2024-11-04T02:36:27Z" - }, { "Category": "Other", "CreatedBy": "ACS", @@ -6117,7 +6117,7 @@ "CreatedDate": "2024-11-06T06:31:58Z", "Description": "{\"en\": \"Bulky query SWAS instance attributes\", \"zh-cn\": \"批量查询轻量应用服务器属性\", \"name-en\": \"ACS-SWAS-BulkyQueryInstanceAttributes\", \"name-zh-cn\": \"批量查询轻量应用服务器属性\"}", "HasTrigger": false, - "Hash": "2da488f192b5b148db80233a6980340197181d3dc3170a14af2661e32f5cb338", + "Hash": "ee0bed138c4dd256618b4ae18b933a313f23b524ad255cd08271d4ec247c77a1", "IsFavorite": false, "Popularity": 0, "ResourceGroupId": "", @@ -6127,10 +6127,10 @@ "TemplateId": "t-429d1f3c4e11414cbe1d", "TemplateName": "ACS-SWAS-BulkyQueryInstanceAttributes", "TemplateType": "Automation", - "TemplateVersion": "v1", + "TemplateVersion": "v2", "TotalExecutionCount": -1, "UpdatedBy": "ACS", - "UpdatedDate": "2024-11-06T06:31:58Z" + "UpdatedDate": "2024-11-19T03:19:05Z" }, { "Category": "Other", @@ -6138,7 +6138,7 @@ "CreatedDate": "2024-11-06T06:31:59Z", "Description": "{\"name-en\": \"ACS-VPC-BulkyQueryInstanceAttributes\", \"name-zh-cn\": \"批量查询VPC属性\", \"en\": \"Bulky query VPC attributes\", \"zh-cn\": \"批量查询VPC属性\"}", "HasTrigger": false, - "Hash": "0519dbf0f75e9be29dabd126fc9cbee2c7a6811a5cc44ba7557622acc712ac20", + "Hash": "b578cf3b232c990fb1ab5771454392d34cd3caf001e6e9a44081be0dbcbc4a3c", "IsFavorite": false, "Popularity": 0, "ResourceGroupId": "", @@ -6148,10 +6148,10 @@ "TemplateId": "t-658cc78219b54aef9689", "TemplateName": "ACS-VPC-BulkyQueryInstanceAttributes", "TemplateType": "Automation", - "TemplateVersion": "v1", + "TemplateVersion": "v2", "TotalExecutionCount": -1, "UpdatedBy": "ACS", - "UpdatedDate": "2024-11-06T06:31:59Z" + "UpdatedDate": "2024-11-19T03:19:05Z" }, { "Category": "Other", @@ -6173,6 +6173,27 @@ "TotalExecutionCount": -1, "UpdatedBy": "ACS", "UpdatedDate": "2024-11-15T05:57:35Z" + }, + { + "Category": "Other", + "CreatedBy": "ACS", + "CreatedDate": "2024-11-19T02:48:58Z", + "Description": "{\"en\": \"Red Hat Enterprise Linux template activation\", \"zh-cn\": \"RHEL模板激活\", \"name-en\": \"ACS-ECS-BulkyActivateRedHatEnterpriseLinux\", \"name-zh-cn\": \"RHEL模板激活\", \"categories\": [\"run_command\", \"application_manage\"]}", + "HasTrigger": false, + "Hash": "047a62051654f57ef62e040e87e88517a8b76ce051982472aab58621cfee2a49", + "IsFavorite": false, + "Popularity": 0, + "ResourceGroupId": "", + "ShareType": "Public", + "Tags": {}, + "TemplateFormat": "YAML", + "TemplateId": "t-2a53c9a230b241f9bf5a", + "TemplateName": "ACS-ECS-BulkyActivateRedHatEnterpriseLinux", + "TemplateType": "Automation", + "TemplateVersion": "v1", + "TotalExecutionCount": -1, + "UpdatedBy": "ACS", + "UpdatedDate": "2024-11-19T02:48:58Z" } ] } diff --git a/templates/ACS-ECS-BulkyActivateRedHatEnterpriseLinux.yaml b/templates/ACS-ECS-BulkyActivateRedHatEnterpriseLinux.yaml new file mode 100644 index 0000000..5f62830 --- /dev/null +++ b/templates/ACS-ECS-BulkyActivateRedHatEnterpriseLinux.yaml @@ -0,0 +1,245 @@ +FormatVersion: OOS-2019-06-01 +Description: + en: Red Hat Enterprise Linux template activation + zh-cn: RHEL模板激活 + name-en: ACS-ECS-BulkyActivateRedHatEnterpriseLinux + name-zh-cn: RHEL模板激活 + categories: + - run_command + - application_manage +Parameters: + regionId: + Type: String + Label: + en: RegionId + zh-cn: 地域ID + AssociationProperty: RegionId + Default: '{{ ACS::RegionId }}' + orderId: + Label: + en: OrderId + zh-cn: 订单号 + Description: + en: The ID of Order + zh-cn: 订单ID + Type: String + 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: '' +RamRole: '{{ OOSAssumeRole }}' +Tasks: + - Name: getInstanceFromOrderId + Action: ACS::WaitFor + Description: + en: Views the ECS instances + zh-cn: 通过订单ID获取ECS实例 + Retries: 10 + DelayType: Exponential + Delay: 2 + BackOff: 2 + Properties: + Service: BssOpenApi + API: GetOrderDetail + Parameters: + RegionId: '{{ regionId }}' + OrderId: '{{ orderId }}' + DesiredValues: + - Paid + StopRetryValues: + - Cancelled + PropertySelector: Data.OrderList.Order[].PaymentStatus + NotDesiredValues: [] + Outputs: + instanceIds: + Type: List + ValueSelector: Data.OrderList.Order[].InstanceIDs | fromjson | .[] + - Name: runCommand + Action: ACS::ECS::ActivateSoftware + Description: + en: Execute cloud assistant command + zh-cn: 执行云助手命令 + Properties: + regionId: '{{ regionId }}' + commandContent: |- + #bin/bash + + # Subscribe to Redhat repo on Alibaba Cloud ECS + + # error code list + # 1: get os version failed by release file + # 2: can not get os version by release file not exists + # 3: not support rhel 7 arm64 + # 4: os not in support list + # 5: download rpm from mirrors site failed + + # rhui repo rpm list + + rhel_7_x86_url="https://mirrors-ssl.aliyuncs.com/pulp/repos/unprotected/alibaba/rhuicli/Packages/c/client-rhel7-3.0-1.el7_9.noarch.rpm" + + rhel_8_x86_url="https://redhat.mirrors.aliyuncs.com/pulp/content/unprotected/alibaba/rhuicli-rhel-8/Packages/a/aliyun_rhui_rhel8-2.0-3.x86_64.rpm" + rhel_8_arm64_url="https://redhat.mirrors.aliyuncs.com/pulp/content/unprotected/alibaba/rhuicli-rhel-8/Packages/a/aliyun_rhui_rhel8-2.0-3.aarch64.rpm" + + rhel_9_x86_url="https://redhat.mirrors.aliyuncs.com/pulp/content/unprotected/alibaba/rhuicli-rhel-9/Packages/a/aliyun_rhui_rhel9-2.0-1.x86_64.rpm" + rhel_9_arm64_url="https://redhat.mirrors.aliyuncs.com/pulp/content/unprotected/alibaba/rhuicli-rhel-9/Packages/a/aliyun_rhui_rhel9-2.0-1.aarch64.rpm" + + ARCH= + OSVER= + + function init_arch_version(){ + ARCH=$(uname -m) + if [ -f /etc/redhat-release ];then + OSVER=$(cat /etc/redhat-release |grep -oP '\d' |head -n 1) + return + fi + if [ -f /etc/os-release ];then + OSVER=$(cat /etc/os-release |grep VERSION_ID |grep -oP '\d' |head -n 1) + return + fi + + if [ -z $OSVER ];then + echo "Unable to get OS version" + exit 1 + fi + + echo "redhat-release & os-release not exist, Unable to get OS version" + exit 2 + } + + function download_rpm_to_local() { + url=$1 + localpath=$2 + wget -q $url -O $localpath + if [ $? -ne 0 ];then + echo "download $url failed" + exit 5 + fi + } + + function rhel_7_x86_subscription() { + echo "Subscribing to Red Hat Enterprise Linux Server 7 x86 repo on Alibaba Cloud ECS" + + download_rpm_to_local $rhel_7_x86_url /tmp/client-rhel7-3.0-1.el7_9.noarch.rpm + rpm -ivh --replacefiles --force /tmp/client-rhel7-3.0-1.el7_9.noarch.rpm + rm -fv /tmp/client-rhel7-3.0-1.el7_9.noarch.rpm + yum clean all + yum makecache + } + + function rhel_7_arm64_subscription() { + echo "not support rhel 7 arm64" + exit 3 + } + + function rhel_8_x86_subscription() { + echo "Subscribing to Red Hat Enterprise Linux Server 8 x86 repo on Alibaba Cloud ECS" + download_rpm_to_local $rhel_8_x86_url /tmp/aliyun_rhui_rhel8-2.0-3.x86_64.rpm + rpm -ivh --replacefiles --force /tmp/aliyun_rhui_rhel8-2.0-3.x86_64.rpm + rm -fv /tmp/aliyun_rhui_rhel8-2.0-3.x86_64.rpm + yum clean all + yum makecache + } + + function rhel_8_arm64_subscription() { + echo "Subscribing to Red Hat Enterprise Linux Server 8 arm64 repo on Alibaba Cloud ECS" + download_rpm_to_local $rhel_8_arm64_url /tmp/aliyun_rhui_rhel8-2.0-3.aarch64.rpm + rpm -ivh --replacefiles --force /tmp/aliyun_rhui_rhel8-2.0-3.aarch64.rpm + rm -fv /tmp/aliyun_rhui_rhel8-2.0-3.aarch64.rpm + yum clean all + yum makecache + } + + function rhel_9_x86_subscription() { + echo "Subscribing to Red Hat Enterprise Linux Server 9 x86 repo on Alibaba Cloud ECS" + download_rpm_to_local $rhel_9_x86_url /tmp/aliyun_rhui_rhel9-2.0-1.x86_64.rpm + rpm -ivh --replacefiles --force /tmp/aliyun_rhui_rhel9-2.0-1.x86_64.rpm + rm -fv /tmp/aliyun_rhui_rhel9-2.0-1.x86_64.rpm + yum clean all + yum makecache + } + + function rhel_9_arm64_subscription() { + echo "Subscribing to Red Hat Enterprise Linux Server 9 arm64 repo on Alibaba Cloud ECS" + download_rpm_to_local $rhel_9_arm64_url /tmp/aliyun_rhui_rhel9-2.0-1.aarch64.rpm + rpm -ivh --replacefiles --force /tmp/aliyun_rhui_rhel9-2.0-1.aarch64.rpm + rm -fv /tmp/aliyun_rhui_rhel9-2.0-1.aarch64.rpm + yum clean all + yum makecache + } + + function main() { + init_arch_version + case "$OSVER$ARCH" in + 7x86_64) + rhel_7_x86_subscription + ;; + 7aarch64) + rhel_7_arm64_subscription + ;; + 8x86_64) + rhel_8_x86_subscription + ;; + 8aarch64) + rhel_8_arm64_subscription + ;; + 9x86_64) + rhel_9_x86_subscription + ;; + 9aarch64) + rhel_9_arm64_subscription + ;; + *) + echo "not support your os, only support rhel 7[x86], rhel 8[x86,arm64], rhel 9[x86,arm64]" + exit 4 + ;; + esac + + } + main + instanceId: '{{ ACS::TaskLoopItem }}' + commandType: RunShellScript + Outputs: + commandOutput: + Type: String + ValueSelector: invocationOutput + Loop: + Items: '{{ getInstanceFromOrderId.instanceIds }}' + RateControl: '{{ rateControl }}' + Outputs: + commandOutputs: + AggregateType: Fn::ListJoin + AggregateField: commandOutput +Outputs: + commandOutputs: + Type: List + Value: '{{ runCommand.commandOutputs }}' +Metadata: + ALIYUN::OOS::Interface: + ParameterGroups: + - Parameters: + - orderId + - regionId + Label: + default: + zh-cn: 配置参数 + en: Configure Parameters + - Parameters: + - rateControl + - OOSAssumeRole + Label: + default: + zh-cn: 高级选项 + en: Control Options + diff --git a/templates/ACS-ECS-BulkyDownloadFile.yaml b/templates/ACS-ECS-BulkyDownloadFile.yaml index 3fa9f0b..36bc89c 100644 --- a/templates/ACS-ECS-BulkyDownloadFile.yaml +++ b/templates/ACS-ECS-BulkyDownloadFile.yaml @@ -60,8 +60,8 @@ Parameters: en: DestinationDir zh-cn: 文件保存路径 Description: - en: The full path of destination directory - zh-cn: 文件在目标机器的完整路径 + en: < Li class = "Li" > The complete path of the file on the target machine. example:linux:/root, windows:E://. + zh-cn:
  • 文件在目标机器的完整路径。例:linux:/root, windows:E://。
  • Type: String Default: /root timeout: diff --git a/templates/ACS-ECS-BulkyModifyInstanceChargeType.yaml b/templates/ACS-ECS-BulkyModifyInstanceChargeType.yaml index b420826..25b2652 100644 --- a/templates/ACS-ECS-BulkyModifyInstanceChargeType.yaml +++ b/templates/ACS-ECS-BulkyModifyInstanceChargeType.yaml @@ -89,6 +89,11 @@ Parameters: - PayByBandwidth - PayByTraffic - '' + AssociationPropertyMetadata: + ValueLabelMapping: + PayByBandwidth: 按固定宽带 + PayByTraffic: 按使用流量 + '': 不修改计费方式 Default: PayByTraffic rateControl: Label: diff --git a/templates/ACS-ECS-CreateImage.yaml b/templates/ACS-ECS-CreateImage.yaml index 2927270..c56bbe0 100644 --- a/templates/ACS-ECS-CreateImage.yaml +++ b/templates/ACS-ECS-CreateImage.yaml @@ -45,6 +45,7 @@ Parameters: en: ImageFamily zh-cn: 镜像族系 Type: String + AssociationProperty: ALIYUN::ECS::Image::ImageFamily Default: '' imageDescription: Label: diff --git a/templates/ACS-ECS-LocalBuildAndDeployOnSingleECS.yaml b/templates/ACS-ECS-LocalBuildAndDeployOnSingleECS.yaml index 017cf99..8dcb0cc 100644 --- a/templates/ACS-ECS-LocalBuildAndDeployOnSingleECS.yaml +++ b/templates/ACS-ECS-LocalBuildAndDeployOnSingleECS.yaml @@ -10,8 +10,11 @@ Parameters: Label: en: Platform zh-cn: 平台 - AssociationProperty: 'ALIYUN::OOS::GitPlatform::Name' + AssociationProperty: ALIYUN::OOS::GitPlatform::Name Default: github + Description: + en: ECS in mainland China may experience unstable GitHub connection. It is recommended to use Gitee first. + zh-cn: 中国内地ECS可能会出现GitHub连接不稳定,建议优先使用Gitee。 AllowedValues: - github - gitee @@ -20,29 +23,29 @@ Parameters: Label: en: Owner zh-cn: 所有者 - AssociationProperty: 'ALIYUN::OOS::GitAccount::Name' + AssociationProperty: ALIYUN::OOS::GitAccount::Name AssociationPropertyMetadata: - Platform: '${platform}' + Platform: ${platform} organization: Type: String Label: en: Organization zh-cn: 组织 Default: '' - AssociationProperty: 'ALIYUN::OOS::GitOrganization::Name' + AssociationProperty: ALIYUN::OOS::GitOrganization::Name AssociationPropertyMetadata: - Platform: '${platform}' - Owner: '${owner}' + Platform: ${platform} + Owner: ${owner} repository: Type: String Label: en: Repository zh-cn: 仓库 - AssociationProperty: 'ALIYUN::OOS::GitRepository::Name' + AssociationProperty: ALIYUN::OOS::GitRepository::Name AssociationPropertyMetadata: - Platform: '${platform}' - Organization: '${organization}' - Owner: '${owner}' + Platform: ${platform} + Organization: ${organization} + Owner: ${owner} instanceId: Label: en: InstanceId @@ -55,15 +58,15 @@ Parameters: AssociationPropertyMetadata: Visible: Condition: - 'Fn::Equals': - - '${platform}' + Fn::Equals: + - ${platform} - Null branch: Label: en: Branch zh-cn: 分支 Description: - en: 'Branch, pull default branch if not set' + en: Branch, pull default branch if not set zh-cn: 代码仓库分支,不填拉取默认分支 Type: String Default: '' @@ -72,13 +75,8 @@ Parameters: en: Download Path zh-cn: 下载路径 Description: - en: >- - The path to download the code. If not set, it will be downloaded to - /root/workspace/{current execution ID}. If you need to specify a path, - please ensure that the path you provide does not have files, otherwise - it will fail to pull. - zh-cn: >- - 将代码下载到您的ECS上的路径。【不填默认下载到/root/workspace/{当前执行的ID}。如您需指定路径,请确保您提供的路径下没有文件,否则会拉取失败。】 + en: The path to download the code. If not set, it will be downloaded to /root/workspace/{current execution ID}. If you need to specify a path, please ensure that the path you provide does not have files, otherwise it will fail to pull. + zh-cn: 将代码下载到您的ECS上的路径。【不填默认下载到/root/workspace/{当前执行的ID}。如您需指定路径,请确保您提供的路径下没有文件,否则会拉取失败。】 Type: String Default: '' isDockerBuild: @@ -86,9 +84,7 @@ Parameters: en: IsDockerBuild zh-cn: 是否使用Docker构建 Description: - en: >- - If yes, it will detect if Docker is already installed on your ECS, and - if not, it will be installed automatically for you. + en: If yes, it will detect if Docker is already installed on your ECS, and if not, it will be installed automatically for you. zh-cn: 如果选择是,会检测您的ECS上是否已安装Docker,如果没有会为您自动安装。 Type: Boolean Default: false @@ -97,26 +93,24 @@ Parameters: en: buildAndDeployScript zh-cn: 构建部署脚本 Description: - en: >- - Script execution takes the root directory of the code as its working - directory. + en: Script execution takes the root directory of the code as its working directory. zh-cn: 脚本执行会以您指定的下载路径作为工作路径。 Type: String MaxLength: 16384 - AssociationProperty: 'ALIYUN::OOS::Command::CommandContent' + AssociationProperty: ALIYUN::OOS::Command::CommandContent AssociationPropertyMetadata: CommandType: RunShellScript Value: - Condition: - 'Fn::Equals': - - '${isDockerBuild}' + Fn::Equals: + - ${isDockerBuild} - true Value: |- - ##### Sample Java Deploy Script - ##### for Docker Build + ##### 请注意不要在这里填写Dockerfile内容,这里应该填写用于构建部署的shell命令,可参考下面的示例。 + ##### Please do not fill in the Dockerfile content here, but fill in the build command, refer to the example below. ### Build latest image - # docker build -t myapp:latest . + # docker build -f Dockerfile -t myapp:latest . # container_name="my-container" ### Stop the previous version of the container (if any) @@ -131,44 +125,30 @@ Parameters: ##### end - Condition: - 'Fn::Equals': - - '${isDockerBuild}' + Fn::Equals: + - ${isDockerBuild} - false - Value: >- + Value: |- ##### Sample Java Deploy Script - ##### for ECS on Alibaba Cloud Linux 3.2104 - - + ### Build jar file. - # set -e - # yum install -y maven-3.5.4 - # mvn package - - - ### Stop the previous version of the application (if any) and deploy - the current version. - - # PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v - "grep" | awk '{print $2}') - + + ### Stop the previous version of the application (if any) and deploy the current version. + # PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}') # if [ -n "$PID" ]; then - # kill -9 $PID - # fi - # java -jar target/sample-spring-1.0-SNAPSHOT.jar & - - + ##### end RamRole: '' Tasks: - Name: GitCodeRepo - Action: 'ACS::CICD::GitCodeRepo' + Action: ACS::CICD::GitCodeRepo Description: 指定代码源,生成临时授权链接 Properties: organization: '{{ organization }}' @@ -180,7 +160,7 @@ Tasks: Type: String ValueSelector: authorizedUrl - Name: LocalBuildAndDeploy - Action: 'ACS::CICD::LocalBuildAndDeploy' + Action: ACS::CICD::LocalBuildAndDeploy Description: 拉取代码,构建并部署应用 Properties: instanceId: '{{ instanceId }}' @@ -191,10 +171,10 @@ Tasks: buildAndDeployScript: '{{ buildAndDeployScript }}' regionId: '{{ ACS::RegionId }}' workingDir: - 'Fn::If': - - 'Fn::Equals': - - '{{ downloadPath }}' - - '' + Fn::If: + - Fn::Equals: + - '{{ downloadPath }}' + - '' - '/root/workspace/{{ACS::ExecutionId}}' - '{{ downloadPath }}' Outputs: @@ -211,7 +191,7 @@ Tasks: Type: String ValueSelector: buildAndDeployOutput Metadata: - 'ALIYUN::OOS::Interface': + ALIYUN::OOS::Interface: ParameterGroups: - Parameters: - platform @@ -231,4 +211,3 @@ Metadata: default: zh-cn: 构建部署配置 en: Build and Deploy Configuration - diff --git a/templates/ACS-ESS-RollingUpdateByDownloadOSSFileAndRunCommand.yaml b/templates/ACS-ESS-RollingUpdateByDownloadOSSFileAndRunCommand.yaml index e69de29..f489568 100644 --- a/templates/ACS-ESS-RollingUpdateByDownloadOSSFileAndRunCommand.yaml +++ b/templates/ACS-ESS-RollingUpdateByDownloadOSSFileAndRunCommand.yaml @@ -0,0 +1,471 @@ +FormatVersion: OOS-2019-06-01 +Description: + en: Rolling update ECS instances that in scaling group by download OOS file and run command + zh-cn: 通过下载OSS文件并执行命令的方式滚动更新伸缩组内的ECS实例 + name-en: ACS-ESS-RollingUpdateByDownloadOSSFileAndRunCommand + name-zh-cn: 通过下载OSS文件并执行命令的方式滚动更新伸缩组内的ECS实例 + categories: + - elastic_manage +Parameters: + invokeType: + Label: + en: InvokeType + zh-cn: 操作类型 + Type: String + AllowedValues: + - invoke + - rollback + scalingGroupId: + Label: + en: ScalingGroupId + zh-cn: 伸缩组ID + Type: String + enterProcess: + Label: + en: EnterProcess + zh-cn: 执行开始要暂停的伸缩组流程 + Type: List + Default: + - ScaleIn + - ScaleOut + - HealthCheck + - AlarmNotification + - ScheduledAction + exitProcess: + Label: + en: ExitProcess + zh-cn: 执行结束要恢复的伸缩组流程 + Type: List + Default: + - ScaleIn + - ScaleOut + - HealthCheck + - AlarmNotification + - ScheduledAction + invokeBucketName: + Type: String + Label: + en: InvokeBucketName + zh-cn: 用于升级的Bucket名称 + invokeObjectName: + Label: + en: InvokeObjectName + zh-cn: 用于升级的Object名称 + Type: String + invokeDestinationDir: + Label: + en: InvokeDestinationDir + zh-cn: 用于升级的文件存储目录 + Type: String + invokeScript: + Label: + en: InvokeScript + zh-cn: 用于升级的脚本 + Type: String + AssociationProperty: Code + Default: '' + rollbackBucketName: + Type: String + Label: + en: RollbackBucketName + zh-cn: 用于回滚的Bucket名称 + rollbackObjectName: + Label: + en: RollbackObjectName + zh-cn: 用于回滚的Object名称 + Type: String + rollbackDestinationDir: + Label: + en: InvokeDestinationDir + zh-cn: 用于回滚的文件存储目录 + Type: String + rollbackScript: + Label: + en: RollbackScript + zh-cn: 用于回滚的脚本 + Type: String + AssociationProperty: Code + Default: '' + sourceExecutionId: + Label: + en: SourceExecutionId + zh-cn: 用于回滚的OOS执行ID + Type: String + Default: '' + whetherSaveToFile: + Label: + en: whetherSaveToFile + zh-cn: 是否将内容下载到特定文件 + Type: Boolean + Default: true + URLExpirationTime: + Label: + en: OOSFileDownloadURLExpirationTime + zh-cn: OSS文件下载链接的过期时间 + Type: Number + Default: 6000 + OSSRegion: + Label: + en: OSSRegion + zh-cn: OSS所在地域 + Description: + en: When the region where the OSS is located is different from the current region, the OSS file will be downloaded through the public network, and the ECS in the scaling group must be able to access the public network. + zh-cn: OSS所在地域和当前地域不同时会通过公网下载OSS文件,需要伸缩组内的ECS能访问公网。 + Type: String + AssociationProperty: RegionId + Default: '{{ ACS::RegionId }}' + batchPauseOption: + Label: + en: BatchPauseOption + zh-cn: 分批模式 + Type: String + AllowedValues: + - Automatic + - FirstBatchPause + - EveryBatchPause + Default: Automatic + batchNumber: + Label: + en: BatchNumber + zh-cn: 分批执行的批次 + Type: Number + MinValue: 1 + MaxValue: 100 + Default: 5 + OOSAssumeRole: + Label: + en: OOSAssumeRole + zh-cn: OOS扮演的RAM角色 + Type: String + Default: '' +RamRole: '{{ OOSAssumeRole }}' +Tasks: + - Name: getLifecycleHook + Action: ACS::ExecuteAPI + Description: + en: Get lifecycle hook + zh-cn: 获取生命周期挂钩 + Properties: + Service: ESS + API: DescribeLifecycleHooks + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + LifecycleHookName: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand + Outputs: + totalCount: + Type: String + ValueSelector: .TotalCount + - Name: choiceNextTask + Action: 'ACS::Choice' + Description: + en: Choose next task by invoke type + zh-cn: 根据升级类型选择任务 + Properties: + DefaultTask: getInstance + Choices: + - When: + 'Fn::Equals': + - rollback + - '{{ invokeType }}' + NextTask: getExecutionInstanceIds + - Name: getInstance + Description: + en: Views the ECS instances + zh-cn: 获取ECS实例 + Action: 'ACS::ExecuteApi' + Properties: + Service: ESS + API: DescribeScalingInstances + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + LifecycleState: InService + CreationTypes: + - AutoCreated + - Attached + Outputs: + instanceIds: + Type: List + ValueSelector: 'ScalingInstances.ScalingInstance[].InstanceId' + - Name: whetherTheScalingGroupInstanceIsEmpty + Action: 'ACS::Choice' + Description: + en: Check whether the instances in the services in the scaling group are empty + zh-cn: 检查伸缩组内服务中的实例是否为空 + Properties: + DefaultTask: whetherToSuspendProcess + Choices: + - When: + 'Fn::Equals': + - [ ] + - '{{ getInstance.instanceIds }}' + NextTask: 'ACS::END' + - Name: whetherToSuspendProcess + Action: 'ACS::Choice' + Description: + en: Choose next task by process + zh-cn: 根据流程值判断是否暂停流程 + Properties: + DefaultTask: suspendProcess + Choices: + - When: + 'Fn::Equals': + - [] + - '{{ enterProcess }}' + NextTask: invokeByDownloadOSSFileAndRunCommand + - Name: suspendProcess + Action: 'ACS::ExecuteAPI' + Description: + en: Suspend process + zh-cn: 暂停伸缩组流程 + Properties: + Service: ESS + API: SuspendProcesses + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + Process: '{{ enterProcess }}' + - Name: invokeByDownloadOSSFileAndRunCommand + Action: ACS::ECS::DownloadOSSFileAndRunCommand + Description: + en: Upgrade by downloading files to the instance and executing commands + zh-cn: 通过下载文件到实例并执行命令的方式进行升级 + Properties: + instanceId: '{{ ACS::TaskLoopItem }}' + bucketName: '{{ invokeBucketName }}' + objectName: '{{ invokeObjectName }}' + URLExpirationTime: '{{ URLExpirationTime }}' + OSSRegion: '{{ OSSRegion }}' + commandContent: '{{ invokeScript }}' + destinationDir: '{{ invokeDestinationDir }}' + whetherSaveToFile: '{{ whetherSaveToFile }}' + Loop: + Items: '{{ getInstance.instanceIds }}' + BatchPauseOption: '{{ batchPauseOption }}' + Concurrency: + 'Fn::CalculateBatch': + - '{{ batchNumber }}' + - '{{ getInstance.instanceIds }}' + Outputs: + commandOutputs: + AggregateType: 'Fn::ListJoin' + AggregateField: commandOutput + Outputs: + commandOutput: + Type: String + ValueSelector: runCommandOutput + - Name: tagInstance + Action: ACS::ExecuteApi + Description: + en: Creates and attaches tag to ECS instance + zh-cn: 创建并挂载标签到ECS实例 + Properties: + Service: ECS + API: TagResources + Parameters: + ResourceIds: + - '{{ ACS::TaskLoopItem }}' + ResourceType: Instance + Tags: + - Key: 'ess:rollingupdate' + Value: 'oos:{{ ACS::ExecutionId }}' + Loop: + Items: '{{ getInstance.instanceIds }}' + Mode: Concurrency + MaxErrors: 0 + Concurrency: 10 + - Name: createLifecycleHookOfUpgrade + When: + Fn::Equals: + - '{{ getLifecycleHook.totalCount }}' + - 0 + Action: ACS::ExecuteAPI + Description: + en: Create lifecycle hook of upgrade + zh-cn: 创建用于升级的生命周期挂钩 + Properties: + Service: ESS + API: CreateLifecycleHook + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + NotificationMetadata: '{"bucketName":"{{ invokeBucketName }}","objectName":"{{ invokeObjectName }}","URLExpirationTime":"{{ URLExpirationTime }}","OSSRegion":"{{ OSSRegion }}","destinationDir":"{{ invokeDestinationDir }}","OSSRegion":"{{ OSSRegion }}","commandContent":"{{ invokeScript }}","timeout":"600","regionId":"${regionId}","instanceIds":"${instanceIds}","lifecycleHookId":"${lifecycleHookId}","lifecycleActionToken":"${lifecycleActionToken}","rateControl":"{\"Mode\":\"Concurrency\",\"MaxErrors\":0,\"Concurrency\":10}","OOSAssumeRole":"OOSServiceRole"}' + LifecycleTransition: SCALE_OUT + LifecycleHookName: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand + NotificationArn: acs:oos:{{ ACS::RegionId }}:{{ACS::AccountId}}:template/ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand + - Name: modifyLifecycleHookOfUpgrade + When: + Fn::Equals: + - '{{ getLifecycleHook.totalCount }}' + - 1 + Action: ACS::ExecuteAPI + Description: + en: Modify lifecycle hook of upgrade + zh-cn: 修改用于升级的生命周期挂钩 + Properties: + Service: ESS + API: ModifyLifecycleHook + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + NotificationMetadata: '{"bucketName":"{{ invokeBucketName }}","objectName":"{{ invokeObjectName }}","URLExpirationTime":"{{ URLExpirationTime }}","OSSRegion":"{{ OSSRegion }}","destinationDir":"{{ invokeDestinationDir }}","commandContent":"{{ invokeScript }}","timeout":"600","regionId":"${regionId}","instanceIds":"${instanceIds}","lifecycleHookId":"${lifecycleHookId}","lifecycleActionToken":"${lifecycleActionToken}","rateControl":"{\"Mode\":\"Concurrency\",\"MaxErrors\":0,\"Concurrency\":10}","OOSAssumeRole":"OOSServiceRole"}' + LifecycleTransition: SCALE_OUT + LifecycleHookName: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand + - Name: whetherToResumeProcesses + Action: 'ACS::Choice' + Description: + en: Choose next task by process + zh-cn: 根据流程值判断是否恢复流程 + Properties: + DefaultTask: resumeProcesses + Choices: + - When: + 'Fn::Equals': + - [] + - '{{ exitProcess }}' + NextTask: 'ACS::END' + - Name: resumeProcesses + Action: 'ACS::ExecuteAPI' + OnSuccess: 'ACS::END' + Description: + en: Resume process + zh-cn: 恢复伸缩组流程 + Properties: + Service: ESS + API: ResumeProcesses + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + Process: '{{ exitProcess }}' + - Name: getExecutionInstanceIds + Action: 'ACS::ExecuteAPI' + Description: + en: Get the instance that has been executed + zh-cn: 获取已经执行过执行脚本的实例 + Properties: + Service: OOS + API: ListExecutions + Parameters: + ParentExecutionId: '{{ sourceExecutionId }}' + Outputs: + instanceIds: + Type: List + ValueSelector: 'Executions[].Parameters.instanceId' + - Name: getExistInstanceIds + Description: + en: Views the ECS instances + zh-cn: 获取ECS实例 + Action: ACS::SelectTargets + Properties: + ResourceType: ALIYUN::ECS::Instance + Filters: + - Type: ResourceIds + ResourceIds: '{{ getExecutionInstanceIds.instanceIds }}' + Outputs: + instanceIds: + Type: List + ValueSelector: Instances.Instance[].InstanceId + - Name: getRollbackProcess + Action: 'ACS::ExecuteAPI' + Description: + en: Views resource parameters + zh-cn: 获取源执行的参数 + Properties: + Service: OOS + API: ListExecutions + Parameters: + ExecutionId: '{{ sourceExecutionId }}' + Outputs: + enterProcess: + Type: List + ValueSelector: 'Executions[].Parameters.enterProcess[]' + exitProcess: + Type: List + ValueSelector: 'Executions[].Parameters.exitProcess[]' + - Name: suspendProcessWithRollBack + Action: 'ACS::ExecuteAPI' + Description: + en: Suspend process + zh-cn: 暂停伸缩组流程 + Properties: + Service: ESS + API: SuspendProcesses + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + Process: '{{ getRollbackProcess.enterProcess }}' + - Name: rollbackByDownloadOSSFileAndRunCommand + Action: ACS::ECS::DownloadOSSFileAndRunCommand + Description: + en: Rollback by downloading files to the instance and executing commands + zh-cn: 通过下载文件到实例并执行命令的方式进行回滚 + Properties: + instanceId: '{{ ACS::TaskLoopItem }}' + bucketName: '{{ rollbackBucketName }}' + objectName: '{{ rollbackObjectName }}' + URLExpirationTime: '{{ URLExpirationTime }}' + OSSRegion: '{{ OSSRegion }}' + commandContent: '{{ rollbackScript }}' + destinationDir: '{{ rollbackDestinationDir }}' + whetherSaveToFile: '{{ whetherSaveToFile }}' + Loop: + Items: '{{ getExistInstanceIds.instanceIds }}' + BatchPauseOption: '{{ batchPauseOption }}' + Concurrency: + 'Fn::CalculateBatch': + - '{{ batchNumber }}' + - '{{ getExistInstanceIds.instanceIds }}' + Outputs: + commandOutputs: + AggregateType: 'Fn::ListJoin' + AggregateField: commandOutput + Outputs: + commandOutput: + Type: String + ValueSelector: runCommandOutput + - Name: modifyLifecycleHookOfRollback + When: + Fn::Equals: + - '{{ getLifecycleHook.totalCount }}' + - 1 + Action: ACS::ExecuteAPI + Description: + en: Modify lifecycle hook of rollback + zh-cn: 修改用于回滚的生命周期挂钩 + Properties: + Service: ESS + API: ModifyLifecycleHook + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + NotificationMetadata: '{"bucketName":"{{ rollbackBucketName }}","objectName":"{{ rollbackObjectName }}","URLExpirationTime":"{{ URLExpirationTime }}","OSSRegion":"{{ OSSRegion }}","destinationDir":"{{ rollbackDestinationDir }}","commandContent":"{{ rollbackScript }}","timeout":"600","regionId":"${regionId}","instanceIds":"${instanceIds}","lifecycleHookId":"${lifecycleHookId}","lifecycleActionToken":"${lifecycleActionToken}","rateControl":"{\"Mode\":\"Concurrency\",\"MaxErrors\":0,\"Concurrency\":10}","OOSAssumeRole":"OOSServiceRole"}' + LifecycleTransition: SCALE_OUT + LifecycleHookName: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand + - Name: whetherToResumeProcessesWithRollback + Action: 'ACS::Choice' + Description: + en: Choose next task by process + zh-cn: 根据流程值判断是否恢复流程 + Properties: + DefaultTask: resumeProcessesWithRollback + Choices: + - When: + 'Fn::Equals': + - [] + - '{{ getRollbackProcess.exitProcess }}' + NextTask: 'ACS::END' + - Name: resumeProcessesWithRollback + Action: 'ACS::ExecuteAPI' + Description: + en: Resume process + zh-cn: 恢复伸缩组流程 + Properties: + Service: ESS + API: ResumeProcesses + Parameters: + ScalingGroupId: '{{ scalingGroupId }}' + Process: '{{ getRollbackProcess.exitProcess }}' +Outputs: + commandOutputs: + Type: List + Value: + 'Fn::If': + - 'Fn::Equals': + - invoke + - '{{ invokeType }}' + - '{{ invokeByDownloadOSSFileAndRunCommand.commandOutputs }}' + - '{{ rollbackByDownloadOSSFileAndRunCommand.commandOutputs }}' + diff --git a/templates/ACS-RDS-BulkyModifySQLCollectorRetention.yaml b/templates/ACS-RDS-BulkyModifySQLCollectorRetention.yaml index 0ec9958..e69de29 100644 --- a/templates/ACS-RDS-BulkyModifySQLCollectorRetention.yaml +++ b/templates/ACS-RDS-BulkyModifySQLCollectorRetention.yaml @@ -1,58 +0,0 @@ -FormatVersion: OOS-2019-06-01 -Description: - en: Modify SQL collector retention - zh-cn: 设置RDS实例的SQL洞察日志保存时长为180天 - name-en: ACS-RDS-BulkyModifySQLCollectorRetention - name-zh-cn: 设置RDS实例的SQL洞察日志保存时长为180天 - categories: - - security -Parameters: - regionId: - Type: String - Label: - en: RegionId - zh-cn: 地域ID - AssociationProperty: RegionId - Default: '{{ ACS::RegionId }}' - instanceIds: - Label: - en: InstanceIds - zh-cn: RDS实例ID列表 - AssociationProperty: ALIYUN::RDS::Instance::InstanceId - AssociationPropertyMetadata: - RegionId: regionId - Type: List - 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: '' -RamRole: '{{ OOSAssumeRole }}' -Tasks: - - Name: modifySQLCollectorRetention - Action: ACS::ExecuteAPI - Description: - en: Modify SQL collector retention - zh-cn: 设置RDS实例的SQL洞察日志保存时长为180天 - Properties: - Service: RDS - API: ModifySQLCollectorRetention - Parameters: - RegionId: '{{ regionId }}' - DBInstanceId: '{{ ACS::TaskLoopItem }}' - ConfigValue: 180 - Loop: - RateControl: '{{ rateControl }}' - Items: '{{ instanceIds }}' - diff --git a/templates/ACS-SWAS-BulkyQueryInstanceAttributes.yaml b/templates/ACS-SWAS-BulkyQueryInstanceAttributes.yaml index ac5d27f..a06d0a3 100644 --- a/templates/ACS-SWAS-BulkyQueryInstanceAttributes.yaml +++ b/templates/ACS-SWAS-BulkyQueryInstanceAttributes.yaml @@ -12,9 +12,9 @@ Parameters: zh-cn: 地域ID AssociationProperty: RegionId Default: '{{ ACS::RegionId }}' - instanceIds: + resourceIds: Label: - en: InstanceIds + en: ResourceIds zh-cn: SWAS实例ID列表 Type: List targetInfos: @@ -50,7 +50,7 @@ Tasks: instanceId: '{{ ACS::TaskLoopItem }}' Loop: RateControl: '{{ rateControl }}' - Items: '{{ instanceIds }}' + Items: '{{ resourceIds }}' Metadata: ALIYUN::OOS::Interface: ParameterGroups: @@ -62,7 +62,7 @@ Metadata: en: Configure Parameters - Parameters: - regionId - - instanceIds + - resourceIds Label: default: zh-cn: 选择实例 diff --git a/templates/ACS-VPC-BulkyQueryInstanceAttributes.yaml b/templates/ACS-VPC-BulkyQueryInstanceAttributes.yaml index 9a8f471..5db5d2e 100644 --- a/templates/ACS-VPC-BulkyQueryInstanceAttributes.yaml +++ b/templates/ACS-VPC-BulkyQueryInstanceAttributes.yaml @@ -12,11 +12,11 @@ Parameters: zh-cn: 地域ID AssociationProperty: RegionId Default: '{{ ACS::RegionId }}' - vpcIds: + resourceIds: Type: List Label: - en: vpcId - zh-cn: VPCId + en: ResourceIds + zh-cn: VPC实例ID列表 AssociationProperty: ALIYUN::ECS::VPC::VPCId AssociationPropertyMetadata: RegionId: regionId @@ -52,7 +52,7 @@ Tasks: regionId: '{{ regionId }}' instanceId: '{{ ACS::TaskLoopItem }}' Loop: - Items: '{{ vpcIds }}' + Items: '{{ resourceIds }}' RateControl: '{{ rateControl }}' Metadata: ALIYUN::OOS::Interface: @@ -65,7 +65,7 @@ Metadata: en: Configure Parameters - Parameters: - regionId - - vpcIds + - resourceIds Label: default: zh-cn: 选择VPC