sql - Chef Cookbook 无法使用执行资源运行 sqllocaldb

标签 sql azure express chef-infra

我已经在这本 Recipe 上苦苦挣扎了一段时间了。

我正在尝试将包括 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 支持此属性。

我包括下面的整个 Recipe :

%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

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

最佳答案

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

关于sql - Chef Cookbook 无法使用执行资源运行 sqllocaldb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25094308/

相关文章:

SQL 聚合函数别名

Azure 资源图查询 - 按订阅名称列出策略状态

Azure SDK 1.8 云驱动

azure - 如何从 Azure IoT 中心获取设备上的日期时间?

node.js - Nodejs 具有快速、静态目录名

javascript - 如何在 Node.js 中使用 php 的 session_id() 之类的东西?

mysql - Sql查询读取多行

c# - SQL 查询参数名称必须定义

SQL - 控制在连接中返回哪些列

node.js - 尽管用户在网站上注销,但 Socket.io 授权仍然存在