Thanks for your reply Kai.
I am using the below task using command module to get the uptime value of 
JBOSS EAP server instance. However still I am receiving error as mentioned 
below.

- name: Check the JBOSS Server Uptime Domain mode
  command: "{{ CLI_SCRIPT }} --connect controller={{ item.hostname }}:{{ 
item.port }} --user={{ jbossuser }} --password={{ jbosspass }} /host={{ 
item.host }}-{{ item.server 
}}/core-service=platform-mbean/type=runtime:read-attribute(name=uptime)| awk 
'/result/ { print $3 }'"
  register: uptime
  delegate_to: remoteserver
  ignore_errors: yes


Error message:
fatal: [127.0.0.1 -> remoteserver]: FAILED! => {"changed": true, "cmd": [
"/opt/jboss/jboss-eap-7.2.0/bin/jboss-cli.sh", "--connect", "controller=
remoteserver:11011", "--user=someuser", "--password=sometext", 
"/host=jbosshost-server/core-service=platform-mbean/type=runtime:read-attribute(name=uptime)|"
, "awk", "/result/ { print $3 }"], "delta": "0:00:09.420046", "end": 
"2018-11-30 
20:05:18.798064", "msg": "non-zero return code", "rc": 1, "start": "2018-11-30 
20:05:09.378018", "stderr": "Duplicate argument '--command'/'--commands'.", 
"stderr_lines": ["Duplicate argument '--command'/'--commands'."], "stdout": 
"", "stdout_lines": []}

I believe we can use Ansible regex, to capture this value.


On Friday, 30 November 2018 19:35:11 UTC-5, Kai Stian Olstad wrote:
>
> On Friday, 30 November 2018 22:39:46 CET Saravanan wrote: 
> > Hi Ansible Experts, 
> > Need help to capture the JBOSS EAP JVM uptime value through Ansible 
> > playbook. From the below task stdout need to parse the uptime value 
> which 
> > is in numeric field to a variable. 
> > 
> > { 
> >     "outcome" => "success", 
> >     "result" => 3613082543L 
> > } 
> > 
> > Can you please suggest the right string parsing method to achieve this? 
> I 
> > was unable to use Unix commands like grep/ awk/ sed to filter this 
> numeric 
> > value. 
>
> You have not provided the task, but if you are using the shell module just 
> add 
>   | awk '/result/ { print $3 }' 
> and you stdout will only contain that value. 
>
>
>
> -- 
> Kai Stian Olstad 
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b9307a8a-192e-4b73-929e-e13496f18f41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to