首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >厨师执行资源不在Rhel 8上工作。

厨师执行资源不在Rhel 8上工作。
EN

Stack Overflow用户
提问于 2020-11-29 19:44:40
回答 1查看 62关注 0票数 1

我正在使用烹饪食谱中的执行资源。菜谱正在正常工作,而菜谱则要求cli。食谱不适用于cron的日程安排。我在下面发送错误日志;

代码语言:javascript
复制
* execute[DNS Recording with Centrify] action run
    
    ================================================================================
    Error executing action `run` on resource 'execute[DNS Recording with Centrify]'
    ================================================================================
    
    Errno::ENOENT
    -------------
    No such file or directory - addns
    
    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/rhel8/recipes/centrify.rb
    
     48:                        execute 'DNS Recording with Centrify' do
     49:                                 command 'addns -U -m'
     50:                                user "root"
     51:                                 ignore_failure false
     52:                        end
     53:                end
    
    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/rhel8/recipes/centrify.rb:48:in `from_file'
    
    execute("DNS Recording with Centrify") do
      action [:run]
      default_guard_interpreter :execute
      command "addns -U -m"
      declared_type :execute
      cookbook_name "rhel8"
      recipe_name "centrify"
      domain nil
      user "root"
    end

我找到了原因。其原因是出现不同路径的游离层。烹饪书在cli和不同的cron中使用不同的路径。我的命令二进制在cli路径中。我不能使用静态路径,因为cli路径会根据操作系统、版本和分布进行更改。

如何根据所有linux在食谱中设置cli路径?

问候

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-30 04:37:22

从问题中可以看出,您希望为execute资源提供相应的execute环境变量。

您可以尝试两个选项:

  1. 在执行命令时设置环境变量PATH

使用Centrify执行'DNS记录‘do命令'addns -U -m’user 'root‘环境({ 'PATH’=> ENV'PATH‘})结束

  1. 或使用资源的default_env属性查看是否使PATH可用:

使用Centrify执行'DNS记录‘do命令'addns -U -m’user 'root‘default_env true end

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65064399

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档