Ansible lm_info devices by group
Hello All,
I am trying to achieve a similar result in Ansible using the LogicMonitor collections modules as I can get with the Rest API using python.
Using rest, I can do something like:
{{url}}/device/groups/{{group_id}}/devices
and I will get a list of all devices for the group specified in ‘group_id’.
I am trying to get the same result using the ansible lm_info module but no luck.
I am not trying to perform any action - just return the info.
I tried using full_path to narrow the device results down but I still get all devices instead of those associated with the group (this is not a collector group but a device group). The group parameter is not supported for lm_info with a target: device but full_path is supposed to be supported.
I am reluctant to even post this question because I am probably missing something really simple 🙄 but …
Thanks in advance
Joseph Glaser
OP3 years agoJust to provide closure, I simply wrote a python script that takes parameters, passed in a value from a previous ansible step and registered the output from the python script to use in subsequent steps.
Not as streamlined as using straight Ansible, but it got the job done.
Thanks for all of the comments.
Have a great weekend
LM User
·3 years agoAgreed. I built up my own little library of functions to along with the SDK.
Joe Williams
·3 years agoYeah, but at that point if I am already writing something to overcome something, plus having to divert from the SDK for a few other things, I may as roll my own code.
Joe Williams
·3 years agoAt least prior, we had inconsistent data types being asked for in the “data” section for a post/put. Sometimes it seemed to want a string, sometimes it wanted an object/dict. We also had issues with returned data. Again this was a while back, but I swear sometimes we got camelcase, sometimes we got the underscored properties. Then we had the issue that you have, where things just weren’t there. Even if it wasn’t in the at the time v2 API, we could backwoods the v3 api via web developer tools in a browser and make things work. So we could easily just add it to the lm_rest function/class we built.
LM User
·3 years agoI’d be interested in the difficulties you ran into with the SDK. I’ve been able to use it except where the method doesn’t exist in the SDK for a specific endpoint in the API (like role groups).
Joe Williams
·3 years agoI doubt you’re missing anything simple. My experience with the Ansible modules is that they are pretty lacking, not enough modules to control enough things to make it possible to control all of LM through Ansible. I wrote my own idempotent sync scripts using the SDK instead of going the Ansible route.
We ended up doing the same as well. I had to write a python module, that emulates the SDK, but uses all the rest endpoints documented. We had to many inconsistent returns from the SDK to use it solely.
LM User
·3 years agoI doubt you’re missing anything simple. My experience with the Ansible modules is that they are pretty lacking, not enough modules to control enough things to make it possible to control all of LM through Ansible. I wrote my own idempotent sync scripts using the SDK instead of going the Ansible route.
Mark_Hensler
·3 years agoI thought I came across this in the Community Feedback category. But I do see it under Product Discussions. My apologies.
Joseph Glaser
OP3 years agoApologies - is this not correct? My first post on the new Community site.
Mark_Hensler
·3 years agoThis should probably be posted in the Product Discussions category.