ansible.builtin.slurp (v2.16.5) — module

Slurps a file from remote nodes

| "added in version" historical of ansible.builtin"

Authors: Ansible Core Team, Michael DeHaan (@mpdehaan)

Install Ansible via pip

Install with pip install ansible-core==2.16.5

Description

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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Find out what the remote machine's mounts are
  ansible.builtin.slurp:
    src: /proc/mounts
  register: mounts
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print returned information
  ansible.builtin.debug:
    msg: "{{ mounts['content'] | b64decode }}"

Inputs

    
src:
    aliases:
    - path
    description:
    - The file on the remote system to fetch. This I(must) be a file, not a directory.
    required: true
    type: path

Outputs

content:
  description: Encoded file content
  returned: success
  sample: MjE3OQo=
  type: str
encoding:
  description: Type of encoding used for file
  returned: success
  sample: base64
  type: str
source:
  description: Actual path of file slurped
  returned: success
  sample: /var/run/sshd.pid
  type: str

See also