I partially answered my own question, from what should have been obvious. 
The variable stack is passed to the lookup plugin.
    self.set_options(var_options=variables, direct=kwargs)
    x = variables['vars']['<variable_name>']

But I am still stuck with a problem. That returns the literal string value 
that was assigned to the variable, it does not evaluate that value.
For example, if I have the following in a vars file
    x: 'a value'
    y: "{{ x }}"

variables['vars']['y'] will return "{{ x }}", not the evaluated result "a 
value".

Is there some other utility function I need to call to force that 
evaluation?

On Monday, August 23, 2021 at 10:56:23 AM UTC-4 John Day wrote:

> I should add that I tried setting environment variables using 
> "environment:" in the play, but those do not appear to be set yet in the 
> process that is running the jinja2 templating.
>
> On Monday, August 23, 2021 at 10:51:16 AM UTC-4 John Day wrote:
>
>> I am building a lookup plugin to help with identifying AWS resource ids 
>> from other relevant resource information, e.g. the Name tag.
>>
>> My issue is that I need the region, access key id, and secret access key 
>> to invoke the boto3 functions and I don't really want to pass these as 
>> arguments to the lookup function on each use.
>>
>> I have these set as both variables and facts in my plays. Is there 
>> something in ansible utilities that I can call to retrieve the variable 
>> value or fact variable from within the lookup plugin?
>>
>> Thanks in advance.
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/ecb38d25-ad7b-461e-9d88-0ecca11c4223n%40googlegroups.com.

Reply via email to