Json 为什么我的CloudFormation命令失败了?
我的命令:Json 为什么我的CloudFormation命令失败了?,json,amazon-web-services,amazon-cloudformation,Json,Amazon Web Services,Amazon Cloudformation,我的命令: "7-set-up-default" : { "command" : { "Fn::Join" : ["", [ "robocopy /move C:\\inetpub\\wwwroot\\ C:\\inetpub\\wwwroot\\Default\\\n", "powershell \"Import-Module WebAdministr
"7-set-up-default" : {
"command" : { "Fn::Join" : ["", [
"robocopy /move C:\\inetpub\\wwwroot\\ C:\\inetpub\\wwwroot\\Default\\\n",
"powershell \"Import-Module WebAdministration;",
"Set-ItemProperty 'IIS:\\Sites\\Default Web Site' -name physicalpath -value 'C:\\inetpub\\wwwroot\\Default\\'\""
]]},
"waitAfterCompletion" : "0"
},
此堆栈跟踪不太有用,因此失败:
Error encountered during build of config: Command 07-set-up-default failed
Traceback (most recent call last):
File "cfnbootstrap\construction.pyc", line 513, in run_config
File "cfnbootstrap\construction.pyc", line 125, in run_commands
File "cfnbootstrap\command_tool.pyc", line 113, in apply
ToolError: Command 07-set-up-default failed
2013-08-18 08:35:29,611 [ERROR] Unhandled exception during build: Command 07-set-up-default failed
Traceback (most recent call last):
File "cfn-init", line 122, in <module>
File "cfnbootstrap\construction.pyc", line 117, in build
File "cfnbootstrap\construction.pyc", line 502, in build
File "cfnbootstrap\construction.pyc", line 513, in run_config
File "cfnbootstrap\construction.pyc", line 125, in run_commands
File "cfnbootstrap\command_tool.pyc", line 113, in apply
ToolError: Command 07-set-up-default failed
有人能帮忙吗?因为robocopy不使用标准返回码。它实际上并没有失败,但命令行将其返回代码解释为失败。看这个 您需要做的是包装robocopy并像这样解释返回值
"a-sync" : {
"command" : {"Fn::Join" : ["",[
"(robocopy c:\\latest c:\\inetpub\\", {"Ref" : "Name"}, " /MIR) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0"
]]},
"waitAfterCompletion" : "1"
},
这是从一个有效的sript中剪切和粘贴的,因此您需要更改参数-但关键部分是将robocopy命令括在括号中,并在^&IF结尾处填充
实际上,它将所有来自robocopy的成功返回代码转换为操作系统识别的成功代码
"a-sync" : {
"command" : {"Fn::Join" : ["",[
"(robocopy c:\\latest c:\\inetpub\\", {"Ref" : "Name"}, " /MIR) ^& IF %ERRORLEVEL% LEQ 4 exit /B 0"
]]},
"waitAfterCompletion" : "1"
},