使用 ansible unarchive 从 tar 存档中提取目录
Extract a directory from tar archive using ansible unarchive
我想从 tar 文件中提取一个目录。
在 Linux OS 中用于安装目录解包 - 我只是这样做:
tar -xvf ingres.tar install
对于 ansible 我试过:
unarchive:
remote_src: yes
src: /ingres/ingres.tar
dest: /ingres
extra_opts:
- "install"
但这当然行不通。有什么想法吗?
GNU tar 命令有一个选项 select 存档成员:--add-file
。 Section 6.2 of the manual 提到它:
If a file name begins with dash (-
), precede it with --add-file
option to prevent it from being treated as an option.
但是,它也适用于其他文件,这意味着您可以在任务的 extra_opts
中将此选项指定为 select 要提取的文件或目录:
unarchive:
remote_src: yes
src: /ingres/ingres.tar
dest: /ingres
extra_opts:
- "--add-file"
- "install"
我想从 tar 文件中提取一个目录。
在 Linux OS 中用于安装目录解包 - 我只是这样做:
tar -xvf ingres.tar install
对于 ansible 我试过:
unarchive:
remote_src: yes
src: /ingres/ingres.tar
dest: /ingres
extra_opts:
- "install"
但这当然行不通。有什么想法吗?
GNU tar 命令有一个选项 select 存档成员:--add-file
。 Section 6.2 of the manual 提到它:
If a file name begins with dash (
-
), precede it with--add-file
option to prevent it from being treated as an option.
但是,它也适用于其他文件,这意味着您可以在任务的 extra_opts
中将此选项指定为 select 要提取的文件或目录:
unarchive:
remote_src: yes
src: /ingres/ingres.tar
dest: /ingres
extra_opts:
- "--add-file"
- "install"