chef cookbook无法使用执行资源运行sqllocaldb

时间:2014-08-02 11:00:57

标签: sql azure express chef

已经在这本食谱上挣扎了一段时间。

我正在尝试将许多资源(包括Azure SDK)安装到Windows Server 2012 R2实例上。

最初我在stacktrace中收到以下错误:

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到服务器然后重新运行厨师,整个食谱将被完美处理并且我的所有资源都已安装。

请注意。我尝试使用retries属性,但我不相信执行支持此属性。

我将以下整个食谱包括在内:

%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

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

1 个答案:

答案 0 :(得分:0)

通常,当您修改环境变量(例如$ PATH)时,它不会在任何正在运行的进程中更新,只会在新启动的进程中更新。这解释了为什么它重新运行它的工作原理; chef-client的新实例选择了新的路径。解决方案是在命令中指定sqllocaldb的完整路径。