ansible unarchive模块从本地计算机复制存档后解压缩

摘要: ansible unarchive模块从本地计算机复制存档后解压缩,ansible,unarchive模块,存档,解压缩,复制,数据库,好用的数据库指南,您值得拥有

attributes

 

生成的文件或目录应具有的属性。

copy

no

yes

如果为true,则将文件从本地“master”复制到目标计算机,否则,插件将在目标计算机上查找src archive。

creates

 

如果指定的绝对路径(文件或目录)已存在,则不会运行此步骤。

decrypt

no

yes

此选项使用Vault控制源文件的自动解密。

dest

 

应解压缩归档的远程绝对路径。

exclude

 

列出要从unarchive操作中排除的目录和文件条目。

extra_opts

 

通过传入数组指定其他选项。

group

 

应该拥有文件/目录的组的名称

keep_newer

no

yes

不要替换比归档文件更新的现有文件。

list_files

no

yes

如果设置为True,则返回tarball中包含的文件列表。

mode

 

生成的文件或目录应具有的权限。

owner

 

应该拥有文件/目录的用户的名称

remote_src

no

yes

设置为yes指示已存档文件已在远程系统上,而不是Ansible控制器的本地文件。

selevel

 

SELinux文件上下文的级别部分

serole

 

SELinux文件上下文的级别部分

setype

 

SELinux文件上下文的级别部分

seuser

 

SELinux文件上下文的级别部分

src

no

yes

如果remote_src=no(默认),将归档文件的本地路径复制到目标服务器; 可以是绝对的或相对的。如果remote_src=yes,目标服务器上的路径要将现有存档文件解压缩。

unsafe_writes

no

yes

影响何时使用原子操作来防止数据损坏或从目标文件读取不一致。

validate_certs

no

yes

这仅适用于使用https URL作为文件源的情况。

注意:需要在远程目标服务器上安装unzip命令
 

可以解压哪些类型:taz\zip\gz

远程目标服务器上将mongodb-linux-i686-2.6.7.tgz解压缩到/root

ansible web -m unarchive -a "src=/root/mongodb-linux-i686-2.6.7.tgz dest=/root remote_src=yes  mode=0755"
 

URL下载文件并解压isis-1.17.0-source-release.zip文件远程服务端

ansible web -m unarchive -a "src=https://mirrors.cnnic.cn/apache//isis/isis-core/isis-1.17.0-source-release.zip dest=/root remote_src=yes"


 

剧本写法:
 


- name: Extract foo.tgz into /var/lib/foo

  unarchive:

    src: foo.tgz

    dest: /var/lib/foo

- name: Unarchive a file that is already on the remote machine

  unarchive:

    src: /tmp/foo.zip

    dest: /usr/local/bin

    remote_src: yes

- name: Unarchive a file that needs to be downloaded (added in 2.0)

  unarchive:

    src: https://example.com/example.zip

    dest: /usr/local/bin

    remote_src: yes

- name: Unarchive a file with extra options

  unarchive:

    src: /tmp/foo.zip

    dest: /usr/local/bin

    extra_opts:

    - --transform

    - s/^xxx/yyy/

 

 

本文由 帝一博客 原创发布。用户在本站发布的原创内容(包括但不仅限于回答、文章和评论),著作权均归用户本人所有。独家文章转载,请联系邮箱:17762131@qq.com。获得授权后,须注明本文地址: https://bubukou.com/shujuku/1974.html

网友留言评论

0条评论