Member-only story

Read a file from remote hosts — Ansible module slurp

How to automate the read of /proc/cpuinfo file from Linux remote host with Ansible. The file is copied as base 64 encoding and decoded with an Ansible Filter.

Luca Berton
5 min readJan 25, 2022

Ansible Read file from remote hosts

  • ansible.builtin.slurp
  • Slurps a file from remote nodes
  • It is used for fetching a base64- encoded blob containing the data in a remote file.

Today we’re talking about the Ansible module `slurp`.

The full name is `ansible.builtin.slurp` which means is part of the collection of modules “builtin” with ansible and shipped with it.

This module is pretty stable and out for years and supports Linux and Windows targets.

The purpose is to slurp a file from a remote location. Please note that the read operation is going to fetch a base64-encoded blob containing the data in a remote file.

Parameters

  • src string — Remote file path

This module has only one parameter “src”, which is also mandatory.

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet