I have a playbook for some hosts which have group variables and host variables that use a custom lookup plugin to extract values from an API endpoint.
ansible_user: "{{ lookup(get_value_from_endpoint) }}"
One important information in the group variables pulled from this API endpoint is ansible_user
, as shown in the example. The username is secured in the API endpoint for security purposes, so that the operator (person using ansible-playbook
or Ansible Tower or AWX) would only need to access the API endpoint and so that the username is not committed to git.
There are also some more information being pulled from the API.
The problem is that the lookup plugin is executed on each task. So if I have 25 tasks in the play, there will be at least 25 API calls.
Is there any way to "cache" this variable so that it will persist through the execution of the play?
Cheers