I have playbook that, when run by itself, looks up various values on the ansible host (e.g. the repository version of a roles directory) and writes them to a log on the ansible target.
The idea being keeping a log of who ran what versions of what playbooks from where. It’s the kind of info you hope to never need but can be invaluable if you do.
Anyway; here’s a snippet.
…
AnsibleGit: “{{ lookup(‘pipe’, ‘git log | head -1’) }}”
…
- shell: echo “{{ EpochTime }} git {{ AnsibleGit }}” >> {{ Log }}
When I include the playbook as one playbook among many in setting up a server (as opposed to running it standalone) the lookups run on
the target rather than the host.
I can make something that gets that information by other means but I’d rather use lookup if I can.
Any ideas how to get lookup to always run on the host?
-david