【发布时间】:2023-04-08 23:56:01
【问题描述】:
我有以下执行 power shell 命令的配方:
powershell_script 'Install' do
cwd 'C:\scripts'
code <<-EOH
powershell C:\\scripts\\pair.ps1 -repo-host #{repohost} -repo-dir #{repodir} -repo-https-port #{repohttpsport} -management-server #{managementserver} -activation-code #{activationcode} -env #{env} -loc #{loc} -role #{role} -app #{app}; Set-ExecutionPolicy -Scope process undefined -Force;
EOH
end
配方基本上是从 Internet 下载一个 pair.sh 文件并将其存储在 c:\scripts 目录中。 这是在食谱的第一部分中实现的。
在引导期间,它被添加到节点并发布引导,它将主厨客户端作为 botstrap 的一部分运行,但失败并出现以下错误:
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com Error executing action `run` on resource 'powershell_script[Insta
ll]'
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com =================================================================
===============
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com **
- Mixlib::ShellOut::ShellCommandFailed
**
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com ------------------------------------
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com Expected process to exit with [0], but received '1'
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com ---- Begin output of "powershell.exe" -NoLogo -NonInteractive -No
Profile -ExecutionPolicy Bypass -InputFormat None -Command ". 'C:/Users/ADMINI~1/AppData/Local/Temp/chef_powershell_scri
pt-user-code20180502-2840-7o4rwn.ps1'" ----
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com STDOUT:
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com STDERR: Thread failed to start.
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com ---- End output of "powershell.exe" -NoLogo -NonInteractive -NoPr
ofile -ExecutionPolicy Bypass -InputFormat None -Command ". 'C:/Users/ADMINI~1/AppData/Local/Temp/chef_powershell_script
-user-code20180502-2840-7o4rwn.ps1'" ----
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com Ran "powershell.exe" -NoLogo -NonInteractive -NoProfile -Executio
nPolicy Bypass -InputFormat None -Command ". 'C:/Users/ADMINI~1/AppData/Local/Temp/chef_powershell_script-user-code20180
502-2840-7o4rwn.ps1'" returned 1
ec2-13-232-54-174.ap-south-1.compute.amazonaws.com [2018-05-02T17:49:46+00:00] FATAL: Mixlib::ShellOut::ShellCommandFail
ed: powershell_script[Install] (illumio2::default line 39) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected
process to exit with [0], but received '1'
ERROR: Failed to execute command on ec2-13-232-54-174.ap-south-1.compute.amazonaws.com return code 1
ERROR: Bootstrap command returned 1
一旦引导失败,当我在此节点上手动运行 chef-clinet 运行时,这将成功完成。
这是一种奇怪的行为,它在引导期间失败,但相同的命令在第一次运行 chef-client 时有效
非常感谢任何解决此错误的线索
谢谢
【问题讨论】:
-
您确定要在那里使用
powershell_script而不是execute?这看起来不像 powershell 代码,它看起来像一个命令。
标签: chef-infra chef-recipe cookbook