TAR提取未按预期进行:
unpack_batch_tar:
archive.extracted:
- name: /aaa/bbb/ccc
- source: http://artifactory-dev/tarstuff/test.tar
- keep_source: False
- archive_format: tar
- skip_verify: True
- overwrite: True
报告错误:
----------
ID: unpack_batch_tar
Function: archive.extracted
Name: /aaa/bbb/ccc
Result: False
Comment: Archive does not have a single top-level directory. To allow this archive to be extracted, set 'enforce_toplevel' to False. To avoid a 'tar-bomb' it may also be advisable to set a top-level directory by adding it to the 'name' value (for example, setting 'name' to /aaa/bbb/ccc/some_dir instead of /aaa/bbb/ccc/).
Started: 05:13:16.376999
Duration: 13.497 ms
为克服此问题,我添加了:
- enforce_toplevel: False
并创建了一个子目录/ aaa / bbb / ccc / some_dir,但是提取没有发生。报告以下错误:
Comment: An exception occurred in this state: Traceback (most recent call last):
File \"/usr/lib/python2.7/site-packages/salt/state.py\", line 1750, in call
**cdata['kwargs'])
File \"/usr/lib/python2.7/site-packages/salt/loader.py\", line 1705, in wrapper
return f(*args, **kwargs)
File \"/usr/lib/python2.7/site-packages/salt/states/archive.py\", line 1252, in extracted
tar.extractall(name)
File \"/usr/lib64/python2.7/tarfile.py\", line 2047, in extractall
self.extract(tarinfo, path)
File \"/usr/lib64/python2.7/tarfile.py\", line 2084, in extract
self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
File \"/usr/lib64/python2.7/tarfile.py\", line 2168, in _extract_member
self.makelink(tarinfo, targetpath)
File \"/usr/lib64/python2.7/tarfile.py\", line 2252, in makelink
os.link(tarinfo._link_target, targetpath)
OSError: [Errno 2] No such file or directory
我没有看到缩进问题,因为同样适用于.JAR文件,但对于.TAR文件却无效。我不确定为什么只有TAR提取失败。