Ansible: Difference between revisions
No edit summary |
No edit summary |
||
Line 35: | Line 35: | ||
</pre> | </pre> | ||
== Modules == | |||
=== get_url === | |||
Downloads files from HTTP, HTTPS or FTP to the remote server. The remote server must have direct access to the remote resource. | |||
By default, if an environment variable <protocol>_proxy is set on the target host, requests will be sent through that proxy. This behaviour can be overridden by setting a variable for this task (see setting the environment), or by using the use_proxy option. HTTP redirects can redirect from HTTP to HTTPS so you should be sure that your proxy environment for both protocols is correct. | |||
From Ansible 2.4 when run with --check, it will do a HEAD request to validate the URL but will not download the entire file or verify it against hashes. For Windows targets, use the win_get_url module instead. | |||
==== Example ==== | |||
<pre> | |||
- name: Download the Asterisk archive | |||
get_url: url={{ asterisk_url }} dest={{ asterisk_source_file }} | |||
register: asterisk_archive | |||
</pre> | |||
==== See also ==== | |||
* https://docs.ansible.com/ansible/latest/modules/get_url_module.html#get-url-module | |||
[[category:system]] | [[category:system]] |
Revision as of 13:30, 16 November 2018
Overview
Ansible 내용 정리.
Options
-i
hosts 파일을 지정한다.
Example
$ ansible -i ./hosts --list-hosts remote hosts (1): 192.168.100.10
-m, --module-name
지정된 모듈을 실행한다.(default=command)
-m MODULE_NAME, --module-name=MODULE_NAME
-u, --user
지정된 사용자로 접속한다. (default=None)
-u REMOTE_USER, --user=REMOTE_USER
Example
$ ansible -i ./hosts remote -m ping -u pchero 192.168.100.10 | SUCCESS => { "changed": false, "ping": "pong" }
Modules
get_url
Downloads files from HTTP, HTTPS or FTP to the remote server. The remote server must have direct access to the remote resource.
By default, if an environment variable <protocol>_proxy is set on the target host, requests will be sent through that proxy. This behaviour can be overridden by setting a variable for this task (see setting the environment), or by using the use_proxy option. HTTP redirects can redirect from HTTP to HTTPS so you should be sure that your proxy environment for both protocols is correct.
From Ansible 2.4 when run with --check, it will do a HEAD request to validate the URL but will not download the entire file or verify it against hashes. For Windows targets, use the win_get_url module instead.
Example
- name: Download the Asterisk archive get_url: url={{ asterisk_url }} dest={{ asterisk_source_file }} register: asterisk_archive