What is the difference between `get_url` and `uri`?
IntermediateConceptAd-hoc Commands, Modules and Idempotency
Answer
get_url downloads a file to the target, with optional checksum verification, and skips the download if the destination already matches. uri makes an HTTP request and returns the response, so it is for APIs, health checks and webhooks.
- ansible.builtin.get_url:
url: https://example.com/app-1.4.2.tar.gz
dest: /tmp/app.tar.gz
checksum: sha256:3b1c...e9
- ansible.builtin.uri:
url: http://localhost:8080/health
status_code: 200
register: health
until: health.status == 200
retries: 10
delay: 3
More on Ad-hoc Commands, Modules and Idempotency
What is an ad-hoc command and what is its syntax?BeginnerWhat does `ansible all -m ping` actually test?BeginnerGive practical use cases for ad-hoc commands.IntermediateWhat is the difference between the `command` and `shell` modules?BeginnerCompare `raw`, `command`, `shell` and `script`.IntermediateWhy prefer a dedicated module over `shell`/`command`?Beginner