Powershell脚本在引导程序期间失败,但在第一个chef-client运行后工作

时间:2018-05-02 18:08:52

标签: chef chef-recipe cookbook

我有以下配方执行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

配方基本上从互联网上下载pair.sh文件并将其存储在c:\ scripts目录中。 这是在食谱的第一部分实现的。

在引导程序期间,它被添加到节点并发布引导程序,它运行chef-client作为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运行时,这就成功完成。

这是一种奇怪的行为,它在引导程序中失败但是同样的命令在第一次主厨 - 客户端运行时起作用

非常感谢任何修复此错误的线索

谢谢

1 个答案:

答案 0 :(得分:0)

尝试使用MaxMemoryPerShellMB等命令在winrm中提升winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}'。厨师的This ticket已经很老了,但报告了类似的问题。

相关问题