如何在CloudFormation模板中将Linux Dynatrace标签命令转为PowerShell
问题:CloudFormation中Windows环境Dynatrace主机标签设置脚本失效排查
我正在编写用于部署EC2实例的CloudFormation模板,需要将以下Linux环境下设置Dynatrace主机标签的命令转换为PowerShell等效命令,确保新创建或迁移的EC2实例能将默认事件正确路由至ServiceNow。
Linux环境下的原命令
sudo su - cd /opt/dynatrace/oneagent/agent/tools ./oneagentctl --set-host-property=o11y-ci=my-new-tag-01 --restart-service
CloudFormation模板中已正常执行的PowerShell命令
模板Metadata中已有两段可正常运行的PowerShell命令:
08_setup_dynatrace-oneagent: commands: 01download_oneagent: command: !Sub 'powershell.exe -Command Read-S3Object -Bucket ${pDynaTraceOneAgentS3Bucket} -Key ${pDynaTraceClusterEnv}/windows/Dynatrace-OneAgent-Windows-Install.exe -File C:\Dynatrace\Dynatrace-OneAgent-Windows-Install.exe' 02install_oneagent: command: !Sub 'powershell.exe -Command C:\Dynatrace\Dynatrace-OneAgent-Windows-Install.exe --set-host-group=${pOperatingCompany}-${pApp}-${pTier}'
我尝试的两种命令格式
我尝试添加了以下两种格式的命令,但在Dynatrace的EC2实例属性和标签中无法找到设置的标签:
第一种:
03configure_oneagent_tag: command: !Sub 'powershell.exe -Command C:\"Program Files"\dynatrace\oneagent\agent\tools; .\oneagentctl --set-host-property=o11y-ci=aws-ent-appmod-01 --restart-service'
第二种:
03configure_oneagent_tag: command: !Sub 'powershell.exe -Command cd C:\”Program Files”\dynatrace\oneagent\agent\tools; .\oneagentctl --set-host-property=o11y-ci=aws-ent-appmod-01 --restart-service'
请问这两段脚本存在什么问题?
内容的提问来源于stack exchange,提问作者Daniel Lewis
相关产品推荐
相关产品推荐

