slurp¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- This module works like M(ansible.builtin.fetch). It is used for fetching a base64- encoded blob containing the data in a remote file.
- This module is also supported for Windows targets.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| src path required |
The file on the remote system to fetch. This I(must) be a file, not a directory. |
Notes¶
Note
- This module returns an 'in memory' base64 encoded version of the file, take into account that this will require at least twice the RAM as the original file size.
Examples¶
- name: Find out what the remote machine's mounts are
ansible.builtin.slurp:
src: /proc/mounts
register: mounts
- name: Print returned information
ansible.builtin.debug:
msg: "{{ mounts['content'] | b64decode }}"
# From the commandline, find the pid of the remote machine's sshd
# $ ansible host -m ansible.builtin.slurp -a 'src=/var/run/sshd.pid'
# host | SUCCESS => {
# "changed": false,
# "content": "MjE3OQo=",
# "encoding": "base64",
# "source": "/var/run/sshd.pid"
# }
# $ echo MjE3OQo= | base64 -d
# 2179
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| content | str | Encoded file content | success |
| encoding | str | Type of encoding used for file | success |
| source | str | Actual path of file slurped | success |
Authors¶
- Ansible Core Team
- Michael Dehaan (@mpdehaan)