天天看点

运维编排场景系列-----批量更新云助手客户端

应用场景

当云助手客户端未自动更新时,需要人为的手动触发去更新云助手客户端。已知需要更新的实例标签,或已知具体实例,执行模版来自动更新目标实例的客户端。

解决方案

模版功能:

1、查找指定的Tags实例,或者指定目标实例。

2、自动升级云助手客户端。

一、打开

控制台

,找到运维编排

运维编排场景系列-----批量更新云助手客户端

二、创建模版

运维编排场景系列-----批量更新云助手客户端

选择空白模版,并点击选取来创建模版。

运维编排场景系列-----批量更新云助手客户端

模版内容:

FormatVersion: OOS-2019-06-01
Description:
  en: Bulky update cloud assostant agent.
  zh-cn: 批量升级云助手客户端。
  name-en: ACS-ECS-BulkyUpdateCloudAssistantAgent
  name-zh-cn: 批量升级云助手客户端
Parameters:
  targets:
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
  rateControl:
    Description:
      en: Concurrency ratio of task execution.
      zh-cn: 任务执行的并发比率。
    Type: Json
    AssociationProperty: RateControl
  OOSAssumeRole:
    Description: The RAM role to be assumed by OOS.
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances.
      zh-cn: 获取ECS实例。
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
  - Name: queryInstanceCommandOutput
    Action: 'ACS::ECS::RunCommand'
    Description:
      en: Invokes ECS instance command and gets invocation output.
      zh-cn: 获取ECS实例。
    Properties:
      commandContent:
        'Fn::Join':
          - |+

          - - version=`ls /usr/local/share/aliyun-assist/`
            - 'versions=`echo $version | sed -e ''s/[ ].*//g''`'
            - /usr/local/share/aliyun-assist/${versions}/aliyun_assist_update --check_update -f
            - newVersion=`ls /usr/local/share/aliyun-assist/`
            - 'newVersions=`echo $newVersion | sed -e ''s/[ ].*//g''`'
            - /usr/local/share/aliyun-assist/${newVersions}/aliyun_assist_update -v
      instanceId: '{{ ACS::TaskLoopItem }}'
      commandType: RunShellScript
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
      Outputs:
        invocation:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
Outputs:
  tagValue:
    Type: String
    Value: '{{ queryInstanceCommandOutput.invocation }}'
           

三、创建执行

模版创建成功后,找到创建的模版,来创建执行。

运维编排场景系列-----批量更新云助手客户端

四、输入参数

当执行模版前,需要首先输入参数,根据实际的需要来选择参数,参数输入完毕后点击下一步:确认,如下图所示。

运维编排场景系列-----批量更新云助手客户端

五、执行模版

当所有的填充内容全部确认无误后,点击创建执行,此时模版开始正式执行。

运维编排场景系列-----批量更新云助手客户端

六、执行结果

如下所示云助手客户端更新到一个新版本。

运维编排场景系列-----批量更新云助手客户端

目标实例中的更新后的客户端版本如下所示。

运维编排场景系列-----批量更新云助手客户端

总结

本模版主要的功能是利用模版的方式,来解决手动或者编写大量的脚本来升级云助手客户端。

欢迎使用OOS

OOS客户支持钉钉群:23330931

OOS管理控制台的链接 OOS帮助文档的链接

系列文章

主题文章

阿里云重磅发布云上自动化利器——运维编排OOS

最佳实践

玩转运维编排服务的权限:Assume Role+Pass Role 阿里云运维编排新功能:一键批量克隆ECS

场景系列

运维编排场景系列----更新ECS镜像 运维编排场景系列-----给ECS实例自动打TAG 运维编排场景系列----从实例中拷贝文件到OSS 运维编排场景系列----给实例加到SLS机器组 运维编排场景系列----检测MFA功能状态 运维编排场景系列-----每日统计多Region实例的运行状态 运维编排场景系列-----如何使用jq 运维编排场景系列----分批到机器上运行命令 运维编排场景系列---更新镜像后自动更新伸缩配置镜像 运维编排场景系列---向Linux实例上传文件 运维编排场景系列---运行远端shell脚本 运维编排场景系列---在ECS实例上运行Ansible-playbook 运维编排场景系列----下载JVM堆栈到OSS 运维编排系列场景-----将实例的固定公网IP转换为其它新EIP 运维编排场景系列----自动定时升级临时带宽