我在
Windows上使用Chef资源执行.当我设置资源的用户属性时,我收到此错误:
Mixlib::ShellOut::InvalidCommandOption -------------------------------------- You must supply both a username and password when supplying a user in windows
这是有道理的,但没有密码属性.我尝试了各种各样的方法,但还没弄明白如何传入.对于这种情况,明文密码不是问题.也许传入密码实际上不是一个功能?看这里(https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout/windows.rb),似乎可以选择密码.
我尝试使用Batch资源.该命令运行正常,直到我设置用户属性.我收到以下错误:
NoMethodError ------------- undefined method `uid' for nil:NilClass
我不知道这些是否应该有用,我做错了什么或者如果它们不起作用我需要一个可能的@R_403_323@.任何帮助表示赞赏!谢谢!
@R_403_323@
情况似乎确实如此. Windows Chef问题的最佳资源通常是Chef邮件列表,因为有几个主要的Windows用户在那里活动.作为一种变通方法,您可以轻松地将资源和提供程序子类化以允许传入密码:
class Chef class Resource::WindowsExecute < Resource::Execute def initialize(name,run_context=nil) super @resource_name = :windows_execute end def password(arg=nil) set_or_return(:password,arg,:kind_of => String) end end class Provider::WindowsExecute < Provider::Execute def shell_out!(cmd,opts) opts[:password] = new_resource.password if new_resource.password super end end end
上面的代码完全未经测试,但您可以尝试将其放入libraries / windows_execute.rb并使用带密码属性的windows_execute资源.我建议阅读https://coderanger.net/chef-secrets/以获取有关如何存储和管理此密码的更多信息.