使用Ansible Unarchive从tar存档中提取目录

罗布森

我想从tar文件中提取一个目录。

在Linux OS中,用于解压缩安装目录-我只需执行以下操作:

tar -xvf ingres.tar install

对于ansible,我尝试了:

unarchive:
  remote_src: yes
  src: /ingres/ingres.tar
  dest: /ingres
  extra_opts:
    - "install"

但这当然行不通。任何的想法?

本·康潘仁

GNU tar命令具有选择存档成员的选项:--add-file手册第6.2节提到了这一点:

如果文件名以破折号(-开头,请在文件名前加上--add-fileoption,以防止将其视为选项。

但是,它也适用于其他文件,这意味着您可以在extra_opts任务的中指定此选项以选择要提取的文件或目录:

unarchive:
  remote_src: yes
  src: /ingres/ingres.tar
  dest: /ingres
  extra_opts:
    - "--add-file"
    - "install"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章