Chef infra 厨师长:远程文件无法通知执行或Ruby_块

Chef infra 厨师长:远程文件无法通知执行或Ruby_块,chef-infra,chef-recipe,Chef Infra,Chef Recipe,大家好,我正在编写下面的代码片段。我尝试了各种组合,但无法从RemoteFile调用管理\u身份验证或授权用户\u ldap 我可以从ruby块“管理操作员”通知管理授权或授权用户\u ldap,但不能从RemoteFile通知 如果manage_operator_标志等于1,我想触发2(manage_auth或authorized_users_ldap)中的任何一个。因此,我尝试在远程_文件上放置一个通知,但并没有被触发。请让我知道我做错了什么 ruby_block "manage_auth"

大家好,我正在编写下面的代码片段。我尝试了各种组合,但无法从RemoteFile调用管理\u身份验证授权用户\u ldap

我可以从ruby块“管理操作员”通知管理授权授权用户\u ldap,但不能从RemoteFile通知

如果manage_operator_标志等于1,我想触发2(manage_authauthorized_users_ldap)中的任何一个。因此,我尝试在远程_文件上放置一个通知,但并没有被触发。请让我知道我做错了什么

ruby_block "manage_auth" do
  block do
    Chef::Log.info("MANAGE AUTH")
  end
  action :nothing
end

ruby_block "manage_operator" do
  block do
    manage_operator_flag = (cfg.fetch("manage.operators", 0) == 1)
    if (manage_operator_flag) then
      f =  Chef::Resource::File::RemoteFile.new("#{node['ucms']['dir']}/bin/ucms_authorized_users_ldap.json", run_context)
      f.source "https://ca.#{c}.#{p}.axiadids.net:4443/ucms_authorized_users_ldap.json"
      f.retries 3
      f.retry_delay 10
      f.ignore_failure true
      # f.run_action :create
      f.action :create
      # f.notifies :run, "execute[authorized_users_ldap]"
      # f.notifies(:run, Chef::Resource::Execute.new("authorized_users_ldap", run_context))
      f.notifies :run, "ruby_block[manage_auth]"
    end
  end
end

execute "authorized_users_ldap" do
  command "touch /tmp/test"
  action :nothing
end

查看
manage\u操作符
ruby块,您应该删除
then
关键字,因为ruby中没有这样的关键字

更改:

if (manage_operator_flag) then
致:

就像您在
manage_auth
ruby块中所做的那样,在条件块中添加日志输出

此外,您还应该以更高的详细度明确执行chef client并检查日志。您可以通过附加来实现,即:

$chef客户端--日志级调试

我还建议您直接使用,而不是使用
ruby\u块
动态调用
remote\u文件
(在运行时)

谢谢您的回答。我可以进入if块并获取远程文件,但是在获取远程文件后,它无法通知ruby_块[manage_auth]@Lavesh:我已经更新了我的答案。请以
debug
日志级别执行chef client,然后更新您的帖子以包含输出。我将尝试相应地更新我的答案。
if (manage_operator_flag)