compute-nest-best-practice/opensource/stablediffusion/oos/ECS-BulkyInstallPluginForStableDiffusion.yaml (139 lines of code) (raw):
FormatVersion: OOS-2019-06-01
Description:
en: Install Plugins
zh-cn: 安装插件
name-en: ACS-ECS-InstallPluginForStableDiffusion
name-zh-cn: 安装插件
Parameters:
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
sourceType:
Type: String
Label:
en: SourceType
zh-cn: 下载方式
AllowedValues:
- https
- github
Default: https
AssociationPropertyMetadata:
RegionId: ${regionId}
sourcePath:
Type: String
Label:
en: SourcePath
zh-cn: 文件来源
Description:
en: <ul class="ul"> <li class="li">Fill in the link address by https</li><li class="li">Fill in the clone address by github</li></ul>
zh-cn: <ul class="ul"> <li class="li">https方式填写链接地址</li><li class="li">github方式填写克隆地址</li></ul>
compressionPackageName:
Type: String
Label:
en: CompressionPackageName
zh-cn: 压缩包名字
Default: 'test.tar.gz'
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${sourceType}
- https
RamRole: ''
Tasks:
- 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: downloadLinuxFile
Action: ACS::ECS::RunCommand
Description:
en: Runs download file command on linux instance
zh-cn: 在linux类型实例上执行下载文件命令
Properties:
instanceId: '{{ ACS::TaskLoopItem }}'
regionId: '{{ regionId }}'
commandType: RunShellScript
timeout: 3600
commandContent: |
test -e /home/extensions/ || mkdir -p /home/extensions/
if [ {{sourceType}} = 'https' ]; then
wget '{{sourcePath}}' -O /home/extensions/{{compressionPackageName}} --no-check-certificate
if [ "$?" != 0 ]; then
echo $_
exit 1
fi
tar -xvf /home/extensions/{{compressionPackageName}}
rm -rf /home/extensions/{{compressionPackageName}}
else
cd /home/extensions/ && git clone '{{sourcePath}}'
fi
docker stop `docker ps |grep aigc|awk -F' ' '{print $1}'`
/etc/init.d/start_sd_docker.sh
for ((i=0;i<100;i++))
do
curl 127.0.0.1:8081
if [ "$?" == 0 ]; then
break
fi
sleep 1
done
Loop:
Items: '{{ getInstance.instanceIds }}'
RateControl:
Mode: Concurrency
MaxErrors: 0
Concurrency: 1
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
Outputs:
commandOutput:
Type: String
Value: '{{ downloadLinuxFile.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: 选择实例
en: Select Instances
- Parameters:
- sourceType
- sourcePath
- compressionPackageName
Label:
default:
zh-cn: 配置参数
en: Configure Parameters