用途: 用于將文件或軟件從http、https或ftp下載到本地節點上
常用參數:
dest: 指定將文件下載的絕對路徑---必須
url: 文件的下載地址(網址)---必須
url_username: 用于http基本認證的用戶名
url_password: 用于http基本認證的密碼
validate_certs: 如果否,SSL證書將不會驗證。這只應在使用自簽名證書的個人控制站點上使用
owner: 指定屬主
group: 指定屬組
mode: 指定權限
案例:
~~~
[admin@node1 ~]$ ansible NFS -m get_url -a "url=http://nginx.org/download/nginx-1.12.2.tar.gz dest=/tmp/"
192.168.20.136 | SUCCESS => {
"changed": true,
"checksum_dest": null,
"checksum_src": "6b41d63befa4f52b0724b533e6292a6671b71fdc",
"dest": "/tmp/nginx-1.12.2.tar.gz",
"gid": 1010,
"group": "admin",
"md5sum": "4d2fc76211435f029271f1cf6d7eeae3",
"mode": "0664",
"msg": "OK (981687 bytes)",
"owner": "admin",
"secontext": "unconfined_u:object_r:user_tmp_t:s0",
"size": 981687,
"src": "/tmp/tmpk78fBY",
"state": "file",
"status_code": 200,
"uid": 1010,
"url": "http://nginx.org/download/nginx-1.12.2.tar.gz"
}
~~~
案例2:
~~~
- name: install_from_source | download php file
get_url: url={{ php_file_url }} dest={{ software_files_path }} validate_certs=no
when: not php_file_result.stat.exists
~~~
- 第一章:Ansible基礎入門
- 第二章:Ansible系列手冊
- 第一節:Ansible系列之主機清單
- 第二節:Ansible系列之變量
- 第三節:Ansible系列之YAML
- 第四節:Ansible系列之條件判斷
- 第五節:Ansible系列之循環
- 第六節: Ansible系列之tags
- 第七節:Ansible系列之Jinja2
- 第三章:Ansible系列之模塊
- 第一節:user模塊
- 第二節:group模塊
- 第三節:cron模塊
- 第四節:copy模塊
- 第五節: file模塊
- 第六節:yum模塊
- 第七節:service模塊
- 第八節:shell模塊
- 第九節:script模塊
- 第十節:setup模塊
- 第十一節:filesystem和mount模塊
- 第十二節:synchronize模塊
- 第十三節: get_url模塊
- 第十四節: package模塊
- 第十五節:stat模塊
- 第十六節:unarchive模塊
- 第十七節: commang模塊
- 第四章:Ansible-playbook介紹
- 第五章:Ansible系統環境
- 第一節:Ansible Role 系統環境之epel設置