如何在盐中调用archive.tar?

nit*_*nms 2 tar salt-stack

我正在尝试解压盐状态文件中的文件.这是相关的状态:

install-file:
#unpack
  archive.tar:
    - options: xjf
    - tarfile: /opt/path/to/file.tar.bz
    - dest: /opt/path/to/
    - watch:
      - file: /opt/path/to/file.tar.bz
#get files
  file.managed:
    - source: salt://pkgs/path/to/file.tar.bz
    - name: /opt/path/to/file.tar.bz
Run Code Online (Sandbox Code Playgroud)

但我不断收到以下错误:

    State: - archive
    Name:      install-sdk
    Function:  tar
        Result:    False
        Comment:   State archive.tar found in sls pkgs.android is unavailable
Run Code Online (Sandbox Code Playgroud)

知道我做错了什么吗?我很确定这不是版本问题.

jbu*_*bub 10

这里的主要问题是没有archive.tar国家.原因可能是对所谓模块和状态的误解.该archive是模块的一些功能,你可以从像CLI调用:

salt '*' archive.tar cjvf /tmp/tarfile.tar.bz2 /tmp/file_1,/tmp/file_2
Run Code Online (Sandbox Code Playgroud)

现在有一种方法可以实际使用您所在州的模块.有一个module.run国家可以做到这一点.我通过archive.tar电话做了一个简单的例子:

untar_file:
  module.run:
    - name: archive.tar
    - options: xjf
    - tarfile: /opt/path/to/file.tar.bz 
    - dest: /opt/path/to/
Run Code Online (Sandbox Code Playgroud)

-name参数指定要运行的模块和函数,其他参数传递给实际函数.

您可以在此处找到传递给tar函数的其他参数:http: //docs.saltstack.com/ref/modules/all/salt.modules.archive.html#salt.modules.archive.tar