FreeKB - Ansible lookup file (read local file)
www.freekb.net › ArticleMar 17, 2021 · The lookup plugin can be used to read a local file. In other words, the lookup plugin reads a file on the control node (that's your Ansible server). On the other hand, the slurp module can be used to read a file on a managed node (e.g. target system). Let's say /tmp/foo.txt contains the following. Line One Line Two
Lookups — Ansible Documentation
docs.ansible.com › playbooks_lookupsNov 02, 2021 · You can populate variables using lookups. Ansible evaluates the value each time it is executed in a task (or template): vars: motd_value: "{ { lookup('file', '/etc/motd') }}" tasks: - debug: msg: "motd value is { { motd_value }}" For more details and a list of lookup plugins in ansible-core, see Working With Plugins.
Lookup plugins — Ansible Documentation
docs.ansible.com › ansible › latestLookup plugins are an Ansible-specific extension to the Jinja2 templating language. You can use lookup plugins to access data from outside sources (files, databases, key/value stores, APIs, and other services) within your playbooks. Like all templating, lookups execute and are evaluated on the Ansible control machine. Ansible makes the data returned by a lookup plugin available using the standard templating system.