Where to put a custom lookup plugin?

290 views
Skip to first unread message

Andrew Cholakian

unread,
Aug 26, 2014, 12:03:46 PM8/26/14
to ansible...@googlegroups.com
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!

Michael DeHaan

unread,
Aug 26, 2014, 6:43:35 PM8/26/14
to ansible...@googlegroups.com
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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/73fb218f-6ee8-4afc-a335-0cdab3455053%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Cholakian

unread,
Aug 30, 2014, 7:49:58 PM8/30/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/lTdnkFQlYa8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

Michael DeHaan

unread,
Sep 2, 2014, 6:54:08 PM9/2/14
to ansible...@googlegroups.com
"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.







Reply all
Reply to author
Forward
0 new messages