Ansible is really designed to put a system configuration into a state, so checking for a possible state is a bit trickier.
But, you could run the playbook in check-only mode, then register the result of the change, then use the results "changed" flag in your script to get the report. For instance, in check-only mode you can say "inbalancer=absent" then any that register "changed == true" you know are not absent, and any that are "changed == false", you know are already absent. This is harder if your state has multiple possibilities (e.g. network port speeds: 10Mbit, 100Mbit, 1Gbit, 10Gbit), but still do-able with the external script. Dan On Tuesday, August 13, 2019 at 8:39:55 AM UTC-5, Ed Greenberg wrote: > > Hi, I have an ansible module that adds and removes servers from the load > balancer. If I do: > > ansible localhost -m modulename -a 'servername=foo inbalancer=present' > > it adds the module to the load balancer and reports changed if it wasn't > there before, and not changed if it was already there. > > Same for 'inbalancer=absent' It takes the server out of the load balancer > and reports changed or not changed. > > So I know if the server is in the balancer when I start through this > section of the code. > > I'd like to have the module set a variable that can be (a) reported on the > output and (b) tested for in a playbook. I'm more interested in reporting, > so I can have a shell script that reports the state of my load balancer and > all it's servers. > > After much reading, I think I need to ask for an approach. > > Thanks, > > Ed Greenbert > > > > > > > > -- 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-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d487375e-b077-4dbe-8c09-3488c1312803%40googlegroups.com.