【问题标题】:chef cookbook cannot run sqllocaldb with execute resource厨师食谱无法使用执行资源运行 sqllocaldb
【发布时间】:2015-10-10 08:19:53
【问题描述】:

已经为这本食谱苦苦挣扎了一段时间。

我正在尝试将包括 Azure SDK 在内的大量资源安装到 Windows Server 2012 R2 实例上。

最初我在堆栈跟踪中收到以下错误:

Generated at 2014-07-01 14:59:23 +0000
Mixlib::ShellOut::ShellCommandFailed: windows_package[WindowsAzureStorageEmulator.msi] 
(azure_sdk::default line 29) had an error: Mixlib::ShellOut::ShellCommandFailed:  
Expected process to exit with [0, 42, 127], but received '1603'
---- Begin output of msiexec /qn /i "c:\chef\chef- 
cache\WindowsAzureStorageEmulator.msi" ----
STDOUT: 
STDERR: 
---- End output of msiexec /qn /i "c:\chef\chef-cache\WindowsAzureStorageEmulator.msi" 
----

我添加了停止、删除、创建和启动的步骤sqllocaldb

但是,现在我收到以下错误:

Generated at 2014-08-02 07:54:19 +0000
Mixlib::ShellOut::ShellCommandFailed: execute[stop-sqllocaldb] (azure_sdk::default line 
18) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with 
[0], but received '1'
---- Begin output of sqllocaldb stop v11.0 ----
STDOUT: 
STDERR: 'sqllocaldb' is not recognized as an internal or external command,operable  
program or batch file.
---- End output of sqllocaldb stop v11.0 ----

我怀疑可能存在某种形式的时间问题(即 sqllocaldb 尚未准备好),因为如果我 ssh 到服务器然后重新运行 chef,整个说明书将得到完美处理,并且我的所有资源都已安装。

注意。我尝试使用 retries 属性,但是我不相信 execute 支持此属性。

我将整个食谱包括在下面:

%w{ SqlLocalDB.msi }.each do |pkg|
  windows_package "#{pkg}" do
    source "https://s3-eu-west-1.amazonaws.com/qainstallerfiles/#{pkg}"
  options "IACCEPTSQLLOCALDBLICENSETERMS=YES /qn"
  installer_type :custom
    action :install
  end
end

%w{ WindowsAzureTools.vs140.exe }.each do |pkg|
  windows_package "#{pkg}" do
    source "https://s3-eu-west-1.amazonaws.com/qainstallerfiles/#{pkg}"
    installer_type :nsis
    action :install
  end
end

execute "stop-sqllocaldb" do
 command "sqllocaldb stop v11.0"
    retries 5
    retry_delay 30 
 action :run
end

execute "delete-sqllocaldb" do
 command "sqllocaldb delete v11.0"
    retries 5
    retry_delay 30 
 action :run
end

execute "delete-WAStorageEmulator" do
 command "del C:\Users\Administrator\WAStorageEmulatorDb3*.*"
 action :run
end

execute "create-sqllocaldb" do
 command "sqllocaldb create v11.0"
    retries 5
    retry_delay 30 
 action :run
end

execute "start-sqllocaldb" do
 command "sqllocaldb start v11.0"
    retries 5
    retry_delay 30 
 action :run
end

%w{ WindowsAzureStorageEmulator.msi }.each do |pkg|
  windows_package "#{pkg}" do
    source "https://s3-eu-west-1.amazonaws.com/qainstallerfiles/#{pkg}"
    retries 5
    retry_delay 30
    action :install
  end
end

%w{ WindowsAzureAuthoringTools-x64.msi}.each do |pkg|
  windows_package "#{pkg}" do
    source "https://s3-eu-west-1.amazonaws.com/qainstallerfiles/#{pkg}"
    action :install
  end
end

%w{ WindowsAzureLibsForNet-x64.msi }.each do |pkg|
  windows_package "#{pkg}" do
    source "https://s3-eu-west-1.amazonaws.com/qainstallerfiles/#{pkg}"
    action :install
  end
end

%w{ WindowsAzureEmulator-x64.exe }.each do |pkg|
  windows_package "#{pkg}" do
    source "https://s3-eu-west-1.amazonaws.com/qainstallerfiles/#{pkg}"
  options '/quiet /msicl ACCEPTLICENSE=1'
  installer_type :custom
    action :install
  end
end

非常感谢您提供的任何帮助。

【问题讨论】:

  • sqllocaldb 二进制文件在您的$Path 中吗?
  • 嗨。是的 sqllocaldb 在路径中。最终。即当我稍后 ssh 并尝试在 powershell 中运行启动命令时,它运行良好。此外,如果我重新运行厨师,那么整个食谱就会成功应用。这就是为什么我想知道时间。 sqllocaldb.msi 是说明书中应用的第一个包,但当我尝试从命令行执行 sqllocaldb 时,几乎好像服务还没有开始
  • 第一次运行时 sqllocaldb 是否不在您的路径上?也许它在之后的路径上,但不是在......如果你在stop-sqllocaldb 中提供 sqllocaldb.exe 的完整路径会发生什么?

标签: sql azure express chef-infra


【解决方案1】:

一般当你修改一个环境变量时,比如$PATH,它不会在任何正在运行的进程中更新,只会在新启动的进程中更新。这解释了为什么重新运行它会起作用; chef-client 的新实例选择了新路径。解决方法是在命令中指定sqllocaldb的完整路径。

【讨论】:

    猜你喜欢
    • 2015-04-02
    • 1970-01-01
    • 2019-02-15
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多