www国产亚洲精品久久小说,在线 | 一区二区三区四区,综合成人亚洲网友偷自拍,中文字幕人妻第一区,最近中文字幕mv

微思網(wǎng)絡(luò)
全國免費電話:400-881-4699
當(dāng)前位置:首頁>微思動態(tài) > >詳情
全國熱線電話 400-881-4699

在線留言

Ansible內(nèi)置模塊之 unarchive

發(fā)布作者:微思網(wǎng)絡(luò)   發(fā)布時間:2024-12-19   瀏覽量:0

ansible.builtin.unarchive 為ansible內(nèi)置模塊之一, 可以用于解壓縮文件到目標(biāo)路徑。它支持多種壓縮格式,包括 tar、zip 等。


1. 選 項 說 明


選項

必須

類型

默認值

說明

src

str

源壓縮文件的路徑

dest

str

遠程受控主機解壓縮文件的目標(biāo)路徑

remote_src

bool

no

如果為 yes,表示 src 是遠程路徑

creates

str

如果路徑存在,則跳過解壓縮操作

list_files

bool

no

如果為 yes,列出壓縮包中的文件,而不是解壓縮

extra_opts

list

傳遞給解壓縮命令的額外選項

mode

str

解壓縮文件的權(quán)限,如 06440755

owner

str

解壓縮文件的所有者

group

str

解壓縮文件的屬組

注意: extra_opts: 額外選項. [type: list]

·         –transform 變形,可以理解為調(diào)用類似 sed 功能替換文本

·         s/^xxx/yyy/ 將開頭的 xxx 文本替換為 yyy

·         –strip-components=1 消去壓縮文件中的第一級目錄


2.  用  例

# 本地的foo.tgz 提取到受控主機/var/lib/foo
- name: Extract foo.tgz into /var/lib/foo
  ansible.builtin.unarchive:
    src: foo.tgz
    dest: /var/lib/foo

#
解壓存檔已經(jīng)在遠程計算機上的文件
- name: Unarchive a file that is already on the remote machine
  ansible.builtin.unarchive:
    src: /tmp/foo.zip
    dest: /usr/local/bin
    remote_src: yes

#
列出壓縮包中的文件
- name: List files in an archive
  ansible.builtin.unarchive:
    src: /path/to/file.zip
    dest: /path/to/destination/
    list_files: yes

#
設(shè)置解壓縮文件的權(quán)限和所有者
- name: Unarchive a file and set permissions and owner
  ansible.builtin.unarchive:
    src: /path/to/file.zip
    dest: /path/to/destination/
    mode: '0755'
    owner: myuser
    group: mygroup

#
解壓縮需要下載的文件(2.0中添加)
- name: Unarchive a file that needs to be downloaded (added in 2.0)
  ansible.builtin.unarchive:
    src: https://example.com/example.zip
    dest: /usr/local/bin
    remote_src: yes

#
使用額外選項解壓縮文件
- name: Unarchive a file with extra options
  ansible.builtin.unarchive:
    src: /tmp/foo.zip
    dest: /usr/local/bin
    extra_opts:
      - --transform
      - s/^xxx/yyy/

#
使用額外選項解壓縮文件2
- name: Unarchive a file with extra options
  ansible.builtin.unarchive:
    src: /path/to/file.tar.gz
    dest: /path/to/destination/
    extra_opts:
      - --strip-components=1


          

Ansible相關(guān)文章推薦


?
返回頂部