所以我有一些代码用于以特定用户身份运行批处理文件。这是我尝试自动化以下语法
runas /user:thisguy "C:\ThisGuysScript.bat"
所以它在Ruby中看起来像这样
Process.create(:command_line => "C:\\ThisGuysScript.bat ", :domain => "MYServer", :with_logon => "thisguy", :password => "thisguyspassword", :cwd =>"C:\\")
所以我试着把它放在厨师和灾难中的食谱中
require 'win32/process'
::Process.create(:command_line => "C:\\ThisGuysScript.bat ", :domain => "MYServer", :with_logon => "thisguy", :password => "thisguyspassword", :cwd =>"C:\\")
失败并出现以下错误
[Tue, 30 Oct 2012 15:57:03 +0000] FATAL: ArgumentError: You must supply a name when declaring a user resource
所以似乎没有意识到我想使用win32 flavor进程。 Chef似乎覆盖了win32模块(我知道食谱是opscode DSL而不是真正的ruby吗?)
有人能够让这个工作吗?或者具有不同实现的相同功能。检查了Windows食谱,但没有发现很多
答案 0 :(得分:3)
听起来你想制作一个用于在Windows机器上创建进程的LWRP。
您获得的错误意味着您有类似
的内容user do # Missing name
gid 500
home "..."
end
正确的语法是
user "apache" do # or whatever the user name should be
# ...
end
如果您的食谱中没有上述内容,则所包含的文件可能包含名为user的变量,这也会导致此问题。
为了回答你的问题,厨师是直接的红宝石,提供了一些功能和框架工作来运行。请注意,厨师运行有几个阶段。我认为你在编译阶段遇到了问题。
制作LWRP似乎是要走的路。如果你不想走那么远,你可以做类似的事情。
ruby_block "Firing process lazers" do
require 'win32/process'
::Process.create(:command_line => "C:\\ThisGuysScript.bat ", :domain => "MYServer", :with_logon => "thisguy", :password => "thisguyspassword", :cwd =>"C:\\")
end