March 2019
Intermediate to advanced
412 pages
9h 49m
English
When reading content from remote hosts, such as with the slurp module (used to read file content from remote hosts into a variable), the content will be Base64 encoded. To decode such content, Ansible provides a b64decode filter. Similarly, if running a task that requires Base64 encoded input, regular strings can be encoded with the b64encode filter.
Let's read content from the derp file, as shown in the following code:
---
- name: demo the filters
hosts: localhost
gather_facts: false
tasks:
- name: read file
slurp:
src: derp
register: derp
- name: display file content (undecoded)
debug:
var: derp.content
- name: display file content (decoded)
debug:
var: derp.content | b64decode
The output is shown in the following screenshot: ...
Read now
Unlock full access