【问题标题】:exctracting a tar file and excluding certain directories and files提取 tar 文件并排除某些目录和文件
【发布时间】:2017-05-17 23:17:21
【问题描述】:

我是新来的厨师,有人可以帮我正确地理解我的语法或执行以下操作的正确方法吗:

remote_file '/tmp/apache-tomcat-8.0.43.tar.gz' do
   source 'http://csjh****1:8000/Tomcat/apache-tomcat-8.0.43.tar.gz'
   user 'root'
   group 'root'
   mode '0755'
   action :create
end

directory '/Apps/Dev/Tomcat/8.0.43' do
    recursive true
    mode 0755
    action :create
end

execute 'extract_some_tar' do
    command = 'tar -xzvf /tmp/apache-tomcat-8.0.43.tar.gz --strip-
    components=1'
    command =  '--exclude=*webapps/examples* '
    command = '--exclude=*webapps/ROOT*'
    command = '--exclude=*webapps/ROOT*'
    cwd '/Apps/Dev/Tomcat/8.0.43'
end

我的厨房出现以下错误:

     ================================================================================
       Error executing action `run` on resource 'execute[extract tomcat tarball]'
       ================================================================================

       Errno::ENOENT
       -------------
       No such file or directory - extract

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen/cache/cookbooks/last_test/recipes/default.rb

【问题讨论】:

    标签: chef-infra


    【解决方案1】:

    command后面不应该有=,你也可以通过在每行末尾添加\来分割你的长字符串。

    execute 'extract_some_tar' do
      command 'tar -xzvf /tmp/apache-tomcat-8.0.43.tar.gz '\
        '--strip-components=1 --exclude=*webapps/examples* '\
        '--exclude=*webapps/ROOT* --exclude=*webapps/ROOT*'
      cwd '/Apps/Dev/Tomcat/8.0.43'
    end
    

    确保为 execute 资源添加一些保护,否则它将在每次 Chef 运行时执行。

    【讨论】:

    • 嗨 Draco,我试过你的命令它不会删除目录。所以在这里我试图将所有内容提取并剥离到目录“/Apps/Dev/Tomcat/8.0.43”中,不包括“示例;根;文档”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 2011-08-01
    • 1970-01-01
    • 2014-03-05
    • 1970-01-01
    • 2010-11-02
    相关资源
    最近更新 更多