skr989
November 18, 2015, 4:07pm
1
I have the below play to check if JBoss application server is RUNNING. I am getting the message “JBoss Process is running on localhost” (inventory_hostname = localhost) even when JBoss is DOWN. Am I doing anything wrong here?
tasks:
name: Check JBOss java process
shell: ps -ef | grep java | grep “jboss.server”
register: jboss_java_process
ignore_errors: false
debug: msg=“JBoss Process is running on {{ inventory_hostname }}”
when: jboss_java_process.stdout.find(“jboss.server”) != -1
-SKR
cosbug
November 19, 2015, 2:48pm
2
Try this way:
when: ‘jboss.server’ in jboss_java_process.stdout
Brian_Coca
(Brian Coca)
November 20, 2015, 11:20pm
3
tasks:
- name: Check JBOss java process
shell: ps -f "jboss.server"
register: jboss_java_process
ignore_errors: false
- debug: msg="JBoss Process is running on {{ inventory_hostname }}"
when: jboss_java_process.stdout_lines|length > 0
rup
(rup)
December 3, 2015, 5:28pm
4
We did it like this:
name: Check for previous running Wildfly instances
shell: ps -ef | grep jboss | grep java | grep -v activemq | grep -v /bin/sh | grep -v grep | awk ‘{print $2}’
register: ps_result
debug: msg=“{{ps_result.stdout}}”
debug: msg=“{{ps_result.stderr}}”
We are also running activemq which uses java processes, so we have to exclude that from our grep results.