厨师LWRP食谱Errno :: ENOENT:没有这样的文件或目录@ dir_s_mkdir

时间:2016-12-09 03:19:03

标签: ruby chef

我正在使用厨师社区java cookbook在CentOS 7.2上安装java。我有一个无效的LWRP配方

我通过java_ark部分

构建我的安装参数
op_sys = node['os']

# Used to get the required java update from the environment file
java_ver_update = node['java_ver']

# Logic for each OS
if op_sys == 'linux'

# Java_ark, which is used to define the correct install attributes for each OS type (win/linux)
  install_dir = node['install_dir']
  java_ark "jdk" do
    url 'http://sv-dc01.sv.local/install_artifacts/java/oracle/JRE/jre-'+"#{java_ver_update}"+'-linux-x64.tar.gz'
    app_home install_dir
    owner 'root'
    group 'wheel'
    app_home_mode 774
    action :install
  end

  # Set the folder permissions
  execute "chown-dir" do
    command "chmod -R 774 #{install_dir}"
    action :run
  end
end

这是我的环境文件,我在其中设置了一些要在主配方中调用的节点属性

name 'env_workstation_dubbo'
description "Environment Workstation Dubbo"
cookbook_versions({
    "ohai" => "> 0.0.1",
    "java" => "> 0.1.0",
    "install_java" => "> 0.0.1"
})

$environment = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
$override = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }

$override['java']['jdk_version'] = '8'
$override['java']['install_flavor'] = 'oracle'
$override['java']['oracle']['accept_oracle_download_terms'] = true
$override['java']['set_default'] = false
# Custom attributes/variables to be placed here
$override['java_ver'] = '8u77'
$override['install_dir'] = '/applications/'


default_attributes(Chef::Mixin::DeepMerge.merge($_default_environment, $environment))
override_attributes($override)

以下是我用于测试的CentOS机器sudo chef-client运行期间发生的情况:

Starting Chef Client, version 12.16.42
resolving cookbooks for run list: ["install_java"]
Synchronizing Cookbooks:
  - install_java (0.2.0)
  - java (1.43.0)
  - compat_resource (12.16.2)
  - ohai (4.2.2)
  - seven_zip (2.0.2)
  - homebrew (2.1.2)
  - apt (5.0.0)
  - build-essential (7.0.2)
  - windows (2.1.1)
  - mingw (1.2.4)
  - ark (2.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
[2016-12-12T11:04:24+13:00] WARN: Chef::Provider::AptRepository already exists!  Cannot create deprecation class for LWRP provider apt_repository from cookbook apt
[2016-12-12T11:04:24+13:00] WARN: AptRepository already exists!  Deprecation class overwrites Custom resource apt_repository from cookbook apt
Converging 8 resources
Recipe: install_java::default
  * java_ark[jdk] action install

    ================================================================================
    Error executing action `install` on resource 'java_ark[jdk]'
    ================================================================================

    Errno::ENOENT
    -------------
    No such file or directory @ dir_s_mkdir - 

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/java/providers/ark.rb:116:in `block (2 levels) in class_from_file'
    /var/chef/cache/cookbooks/java/providers/ark.rb:115:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/install_java/recipes/default.rb

     18:   java_ark "jdk" do
     19:     url 'http://sv-dc01.sv.local/install_artifacts/java/oracle/JRE/jre-'+"#{java_ver_update}"+'-linux-x64.tar.gz'
     20:     app_home install_dir
     21:     owner 'root'
     22:     group 'wheel'
     23:     app_home_mode 774
     24:     action :install
     25:   end
     26: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/install_java/recipes/default.rb:18:in `from_file'

    java_ark("jdk") do
      action [:install]
      supports {:report=>true, :exception=>true}
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :java_ark
      cookbook_name "install_java"
      recipe_name "default"
      url "http://sv-dc01.sv.local/install_artifacts/java/oracle/JRE/jre-8u77-linux-x64.tar.gz"
      app_home "/applications/"
      owner "root"
      group "wheel"
      app_home_mode 774
    end

    Platform:
    ---------
    x86_64-linux


Running handlers:
[2016-12-12T11:04:25+13:00] ERROR: Running exception handlers
Running handlers complete
[2016-12-12T11:04:25+13:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 17 seconds
[2016-12-12T11:04:25+13:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-12-12T11:04:25+13:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-12-12T11:04:25+13:00] ERROR: java_ark[jdk] (install_java::default line 18) had an error: Errno::ENOENT: No such file or directory @ dir_s_mkdir - 
[2016-12-12T11:04:25+13:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

我不能为我的生活弄清楚为什么它找不到文件或目录或者完成Java的安装工作???

1 个答案:

答案 0 :(得分:0)

可能您的环境未正确应用。我的意思是,如果您的计算机未使用'env_workstation_dubbo'环境,则node['install_dir']属性将无法正确设置。您可以阅读如何为节点here设置环境。

另一种可能性是您使用java食谱的修改版本,该修订版使用mkdir代替mkdir_p。我这样说是因为我无法在超市找到你的2.0.0 java食谱版本。你从哪里拿到那本食谱?

降级为java食谱版本v1.43.0

后更新

问题是install_dir必须至少有2个目录级别,遵循app_root/app_name格式。例如"/applications/default"

如果您使用"/applications"作为install_dir,则app_name将为"applications"app_root将为空,后者将在尝试时导致mkdir错误创建应用程序根目录。