ansible.builtin.file (v2.4.6.0-1) — lookup

read file contents

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

Authors: Daniel Hokka Zakrisson <daniel@hozac.com>

Install Ansible via pip

Install with pip install ansible==2.4.6.0.post1

Description

This lookup returns the contents from a file on the Ansible controller's file system.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug: msg="the value of foo.txt is {{lookup('file', '/etc/foo.txt') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: display multiple file contents
  debug: var=item
  with_file:
    - "/path/to/foo.txt"
    - "bar.txt"  # will be looked in files/ dir relative to play or in role
    - "/path/to/biz.txt"

Inputs

    
_terms:
    description: path(s) of files to read
    required: true

Outputs

_raw:
  description:
  - content of file(s)