Parsing output from CLI

99 views
Skip to first unread message

Adam Shantz

unread,
Sep 26, 2016, 2:33:17 PM9/26/16
to Ansible Project
Hi - 

I'm at a point in my Ansible development where I think I need to write a module.  We use a third party messaging server called SwiftMQ.  It's very similar to RabbitMQ & ActiveMQ.  SwiftMQ (SMQ) doesn't provide an API for determining if objects exist or attribute values.  Instead, it provides a CLI to execute a series of commands & you can execute the CLI with an input file.

Likewise, if you want to retrieve values via the CLI, you can output to a text file.  It's primative, but it works and runtime is extremely fast.

Does anyone have experience with having to parse CLI output to determine if & what values need to change?  If so, do you have any advice?  Is there an alternative approach that I haven't considered?

Thanks.

Dick Davies

unread,
Sep 26, 2016, 5:54:40 PM9/26/16
to ansible list
I've got a similar job on my todo list - using the JBoss CLI to
get/set state on a runtime
domain (ansible-xml would make managing config a doddle but editing
the raw xml is a big no-no
in JBoss land).

I made a start on a role to manage it, mainly with command: tasks,
register variables and when: clauses.
One task would check desired state, then a 'setter' would fire
conditionally if state needed to change.

It's nigh on impossible in my case since the jboss CLI is so
inconsistent, but you might get somewhere
if your CLI is less quirky.

http://docs.ansible.com/ansible/playbooks_conditionals.html


A custom module is probably the right approach, it's on my todo list

http://docs.ansible.com/ansible/developing_modules.html
> --
> 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/21ef6210-3f4a-4846-bc0d-dfa7febab4bd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages