1.9 KiB
1.9 KiB
ansible.builtin.fetch
- Fetch files from remote nodes
- This module works like ansible.builtin.copy, but in reverse.
- It is used for fetching files from remote machines and storing them locally in a file tree, organized by hostname.
- Files that already exist at dest will be overwritten if they are different than the src.
Parameter
Parameter | Type | Default | Description |
---|---|---|---|
dest | string / required | - | A directory to save the file into. |
fail_on_missing | boolean | true | When set to true , the task will fail if the remote file cannot be read for any reason. |
src | string / required | - | The file on the remote system to fetch. This must be a file, not a directory. |
validate_checksum | boolean | true | Verify that the source and destination checksums match after the files are fetched. |
Examples
- name: Store file into /tmp/fetched/host.example.com/tmp/somefile
ansible.builtin.fetch:
src: /tmp/somefile
dest: /tmp/fetched
- name: Specifying a path directly
ansible.builtin.fetch:
src: /tmp/somefile
dest: /tmp/prefix-{{ inventory_hostname }}
flat: yes
- name: Specifying a destination path
ansible.builtin.fetch:
src: /tmp/uniquefile
dest: /tmp/special/
flat: yes
- name: Storing in a path relative to the playbook
ansible.builtin.fetch:
src: /tmp/uniquefile
dest: special/prefix-{{ inventory_hostname }}
flat: yes