Where to put a custom lookup plugin?

I need to use a custom lookup plugin to pull our JSON customer database from s3. I have two questions:

  1. Where in the file structure should the file go
  2. Can a lookup plugin return a complex type like a hash?

Thanks in advance!

Note that lookup plugins will get executed once per host, it may be better to download it once from s3 and then load it via a lookup plugin to avoid s3 hammering.

You could really put the file anywhere you want, though something outside of your git directory seems wise, or otherwise configure .gitignore

Yes, a structure could look like this:

{{ lookup(‘file’, ‘/path/to/file’) | to_json }}

I don’t know how complex your infrastructure is, but you may also wish to consider a custom inventory plugin that loads in those variables instead - it would be easier, and PERHAPS more appropriate.

But if you have a small infrastructure maybe not. If you are trying to model a large MSP environment, absolutely.

Michael thanks for the response!

Maybe I missed something, but how do I have a custom inventory declare a variable global to all hosts in every group? I should mention I’m actually using ec2.py right now, and I’m comfy using that. The docs are a little confusing to me on this point.

"Maybe I missed something, but how do I have a custom inventory declare a variable global to all hosts in every group? "

You can set a variable on the ‘all’ group and it will be available to all groups, but override-able in child groups. This is probably what you want to do.