为什么 salt archive.extracted 命令创建相同的嵌套根目录

why salt archive.extracted command create the same nested root directory

我正在尝试使用 salt archive.extracted 命令提取 tar 文件

它的状态框架是这样的:

download_extract:
archive.extracted:
    - name: /opt/
    - if_missing: /opt/
    - source: {{ settings.binaries_url }}
    - source_hash: {{ settings.hash_url }}
    - user: {{ settings.env.user }}
    - group: {{ settings.env.user }}
    - enforce_ownership_on: /opt/

tar 包含一个根目录( /​​foo 及其下的文件)。

我期望得到的是:

/opt/foo/*all the content @ foo*

但我得到的是:

/opt/foo/foo/*all the content @ foo*

你能帮忙吗?

谢谢。

您的 tar 存档可能有一个顶级目录或引导目录。 您可以通过添加以下两项来跳过此目录。

download_extract:
  archive.extracted:
    - name: /opt/
    - if_missing: /opt/
    - source: {{ settings.binaries_url }}
    - source_hash: {{ settings.hash_url }}
    - user: {{ settings.env.user }}
    - group: {{ settings.env.user }}
    - enforce_ownership_on: /opt/
    - enforce_toplevel: False
    - options: --strip-components=1