I’ve just started to play around with ansible to see if it can be used to manage a san controller.
Within the san controller that I’m dealing with, the command “shell” environment is limited (no python). Therefore I can only use the raw module to invoke commands (which is fine for running straight commands).
What I need to do is to parse the output of one (or more) commands to build up the next command.
Here is an example:
I have two san controllers, that are using a hardware mirror between them. I need to “shutdown” the one SAN which breaks down to the following tasks (it’s assuming that the systems “talking” to the san
are inactive)
-
Get a list of the current hosts on SAN A
-
For each host, get a list of the mapped volumes on SAN A
-
For each volume stop the mirroring to SAN B
-
For each volume unmap the volume to the host
-
On SAN B map the “mirrored” volume to the host
The output from the SAN commands span multiple lines, which have to be parsed, etc.
My stab at this was trying to write an ansible module that would “understand” the workings of the san controller and perform the entire task. However, the way that ansible wants to use the module is to load it into the target node (the SAN).
I saw that the other way of doing this would be to use a “local” connection, and pass the host, ids, passwords, etc. to the module, but this seems to be awkward.
I guess what I’m trying to figure out (if it’s possible), is to have a module that can behave like the raw module, but with some more smarts to it. So far I haven’t really seen the ability to do this. If it’s not directly possible, maybe a feature request for ansible to have a class of module(s) that can run like the raw command.
-or- is there a different way I should be approaching this?