ansible / ansible.builtin / v2.7.7 / module / fetch Fetches a file from remote nodes | "added in version" 0.2 of ansible.builtin" Authors: Ansible Core Team, Michael DeHaan stableinterface | supported by coreansible.builtin.fetch (v2.7.7) — module
pip
Install with pip install ansible==2.7.7
This module works like M(copy), but in reverse. It is used for fetching files from remote machines and storing them locally in a file tree, organized by hostname.
This module is also supported for Windows targets.
# Store file into /tmp/fetched/host.example.com/tmp/somefile - fetch: src: /tmp/somefile dest: /tmp/fetched
# Specifying a path directly - fetch: src: /tmp/somefile dest: /tmp/prefix-{{ inventory_hostname }} flat: yes
# Specifying a destination path - fetch: src: /tmp/uniquefile dest: /tmp/special/ flat: yes
# Storing in a path relative to the playbook - fetch: src: /tmp/uniquefile dest: special/prefix-{{ inventory_hostname }} flat: yes
src: description: - The file on the remote system to fetch. This I(must) be a file, not a directory. Recursive fetching may be supported in a later release. required: true dest: description: - A directory to save the file into. For example, if the I(dest) directory is C(/backup) a I(src) file named C(/etc/profile) on host C(host.example.com), would be saved into C(/backup/host.example.com/etc/profile) required: true flat: default: 'no' description: - Allows you to override the default behavior of appending hostname/path/to/file to the destination. If dest ends with '/', it will use the basename of the source file, similar to the copy module. Obviously this is only handy if the filenames are unique. type: bool version_added: '1.2' version_added_collection: ansible.builtin fail_on_missing: default: 'yes' description: - When set to 'yes', the task will fail if the remote file cannot be read for any reason. Prior to Ansible-2.5, setting this would only fail if the source file was missing. - The default was changed to "yes" in Ansible-2.5. type: bool version_added: '1.1' version_added_collection: ansible.builtin validate_checksum: aliases: - validate_md5 default: 'yes' description: - Verify that the source and destination checksums match after the files are fetched. type: bool version_added: '1.4' version_added_collection: ansible.builtin