Hi guys I would like to parse specifc JSON files, create objects from them and store them in memory for further lookup (for my usecase I can't use jmespath). So I plan to read once the whole json file into dictionary with key = ipAdress, value = class. Using a task I would like to run a lookup(ip) and retrieve the class i.e. as dictionary.
In pure python it works pretty well. But I can not figure out how I do embed it in ansible. First I tried with FilterPlugin but it seems I can not use my pydantic classes and putting the code in subdirectory as module was not working. Then I tried as a AnsibleModule. Which works but I can not reuse the class holding my dictionary of parsed itesm. I assume it is because Modules are made for exection on the target host and not the core itself.. Anyway, in python a tried an approach using subfolder/module (__init__.py) and global variable to use singleton pattern. Somthing like this should also work for ansible. But I really don't know what is best approach for this? Mabye LookupPlugin? But how can I initially load the json data? Does it accept to call other methods like a Module? Hope you can help me or even better give me an example how to achieve that. Many thanks in advance for your help! Best regards, Thomas -- 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/d53dbee4-fbf2-4c09-b80e-e6a02b0d2e4en%40googlegroups.com.