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

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

在線(xiàn)留言

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

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

640.png


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

ansible.builtin.get_url 模塊用于從 HTTP、HTTPS 或 FTP 服務(wù)器下載文件到目標(biāo)主機(jī)。它支持驗(yàn)證下載的文件、設(shè)置文件權(quán)限和所有者等功能。


1. 選 項(xiàng) 說(shuō) 明

選項(xiàng)必須類(lèi)型默認(rèn)值說(shuō)明
urlstr無(wú)要下載文件的 URL
deststr無(wú)目標(biāo)文件路徑
modestr無(wú)目標(biāo)文件的權(quán)限,如 0644、0755 等
ownerstr無(wú)目標(biāo)文件的所有者
groupstr無(wú)目標(biāo)文件的屬組
checksumstrno用于驗(yàn)證下載文件的 SHA256 校驗(yàn)和
forcebool無(wú)如果目標(biāo)文件存在,是否強(qiáng)制覆蓋
timeoutintno設(shè)置下載的超時(shí)時(shí)間(秒)
headerslist無(wú)用于下載請(qǐng)求的 HTTP 頭
url_passwordstr無(wú)用于下載請(qǐng)求的密碼
url_usernamestr無(wú)用于下載請(qǐng)求的用戶(hù)名
validate_certsboolyes如果為 no,忽略 SSL 證書(shū)驗(yàn)證錯(cuò)誤
use_proxyboolyes是否使用系統(tǒng)中定義的代理
client_certstr無(wú)用于下載請(qǐng)求的客戶(hù)端證書(shū)文件路徑
client_keystr無(wú)用于下載請(qǐng)求的客戶(hù)端密鑰文件路徑
http_agentstransible-httpget設(shè)置下載請(qǐng)求的 HTTP User-Agent 頭


2. 用 例

# 下載文件到目標(biāo)路徑
- name: Download a file
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz

#
設(shè)置文件權(quán)限和所有者
- name: Download a file and set permissions and owner
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz
    mode: '0644'
    owner: myuser
    group: mygroup


#
使用自定義HTTP
- name: Download a file with custom HTTP headers
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz
    headers:
      - 'Authorization: Basic {{ auth_token }}'

#
使用客戶(hù)端證書(shū)和密鑰
- name: Download a file with client certificate and key
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz
    client_cert: /path/to/client_cert.pem
    client_key: /path/to/client_key.pem

#
下載文件并強(qiáng)制覆蓋現(xiàn)有文件
- name: Download a file and force overwrite if it exists
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz
    force: yes

#
在下載文件時(shí)忽略SSL 證書(shū)錯(cuò)誤
- name: Download a file and ignore SSL certificate errors
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz
    validate_certs: no

#
下載帶有自定義HTTP 頭的文件
- name: Download file with custom HTTP headers
  ansible.builtin.get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    headers:
      key1: one
      key2: two

#
下載并用checksum (sha256)驗(yàn)證文件完整性
- name: Download file with check (sha256)
  ansible.builtin.get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    checksum: sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c

#
下載并用checksum (md5)驗(yàn)證文件
- name: Download file with check (md5)
  ansible.builtin.get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    checksum: md5:66dffb5228a211e61d6d7ef4a86f5758

#
下載并驗(yàn)證文件的校驗(yàn)和(變量提供校驗(yàn)和)
- name: Download a file and verify checksum
  ansible.builtin.get_url:
    url: https://example.com/file.tar.gz
    dest: /tmp/file.tar.gz
    checksum: 'sha256:{{ expected_checksum }}'

#
下載并用帶有checksum (md5) 遠(yuǎn)程文件來(lái)驗(yàn)證文件
- name: Download file with checksum url (sha256)
  ansible.builtin.get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    checksum: sha256:http://example.com/path/sha256sum.txt

#
獲取需要身份驗(yàn)證的文件
- name: Fetch file that requires authentication.
# username/password only available since 2.8, in older versions you need to use url_username/url_password
  ansible.builtin.get_url:
    url: http://example.com/path/file.conf
    dest: /etc/foo.conf
    username: bar
    password: '{{ mysecret }}'

          

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


RHCE.jpg


?
返回頂部