exctracting tar文件并排除某些目录和文件

时间:2017-05-17 10:41:58

标签: chef

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

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

1 个答案:

答案 0 :(得分:0)

=后应该没有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运行时执行。