error run shell script for start service jboss

25 views
Skip to first unread message

Jhon J. Castro H.

unread,
Feb 22, 2019, 3:59:49 PM2/22/19
to Ansible Project
PLAYBOOK:
- hosts: all
gather_facts: yes
remote_user: root
become: yes
tasks:
- name: Inicializa Servicio JBOSS 1.1
shell: sh /home/jboss/jboss-6.4/bin/standalone.sh
ignore_errors: yes
- name: Inicializa Servicio JBOSS 1.2
command: sh /home/jboss/jboss-6.4/bin/standalone.sh
ignore_errors: yes
delegate_to: localhost

- name: Inicializa Servicio JBOSS 2.1
script: /home/jboss/jboss-6.4/bin/standalone.sh
ignore_errors: yes

- name: Inicializa Servicio JBOSS 3.1
script: standalone.sh
args:
chdir: /home/jboss/jboss-6.4/bin
ignore_errors: yes

- name: Inicializa Servicio JBOSS 4.1
shell: /home/jboss/jboss-6.4/bin/./standalone.sh
ignore_errors: yes
- name: Inicializa Servicio JBOSS 4.1
command: /home/jboss/jboss-6.4/bin/./standalone.sh
ignore_errors: yes

- name: Inicializa Servicio JBOSS 5.1
local_action: command sh /home/test_user/test.sh
ignore_errors: yes


RUN FROM AWX
1 Using /var/lib/awx/projects/_6__github_jhon/ansible.cfg as config file
2
SSH password:
3
/tmp/awx_721_8g4184r9/tmpz6redx2g did not meet host_list requirements, check plugin documentation if this is unexpected
4
5
PLAY [all] *********************************************************************
17:42:06
6
7
TASK [Gathering Facts] *********************************************************
17:42:06
8
ok: [vm_for_jboss]
9
10
TASK [Inicializa Servicio JBOSS 1.1] *******************************************
17:42:27
11
fatal: [vm_for_jboss]: FAILED! => {"changed": true, "cmd": "sh /home/jboss/jboss-6.4/bin/standalone.sh", "delta": "0:00:00.035393", "end": "2019-02-22 17:45:47.187417", "msg": "non-zero return code", "rc": 127, "start": "2019-02-22 17:45:47.152024", "stderr": "/home/jboss/jboss-6.4/bin/standalone.sh: line 306: java: command not found", "stderr_lines": ["/home/jboss/jboss-6.4/bin/standalone.sh: line 306: java: command not found"], "stdout": "=========================================================================\n\n JBoss Bootstrap Environment\n\n JBOSS_HOME: /home/jboss/jboss-6.4\n\n JAVA: java\n\n JAVA_OPTS: -server -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true\n\n=========================================================================", "stdout_lines": ["=========================================================================", "", " JBoss Bootstrap Envi…
...
13
14
TASK [Inicializa Servicio JBOSS 1.2] *******************************************
17:42:28
15
fatal: [vm_for_jboss -> localhost]: FAILED! => {"changed": true, "cmd": ["sh", "/home/jboss/jboss-6.4/bin/standalone.sh"], "delta": "0:00:00.408425", "end": "2019-02-22 20:42:28.632028", "msg": "non-zero return code", "rc": 127, "start": "2019-02-22 20:42:28.223603", "stderr": "sh: /home/jboss/jboss-6.4/bin/standalone.sh: No such file or directory", "stderr_lines": ["sh: /home/jboss/jboss-6.4/bin/standalone.sh: No such file or directory"], "stdout": "", "stdout_lines": []}
16
...ignoring
17
18
TASK [Inicializa Servicio JBOSS 2.1] *******************************************
17:42:28
19
fatal: [vm_for_jboss]: FAILED! => {"changed": false, "msg": "Could not find or access '/home/jboss/jboss-6.4/bin/standalone.sh' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}
20
...ignoring
21
22
TASK [Inicializa Servicio JBOSS 3.1] *******************************************
17:42:28
23
fatal: [vm_for_jboss]: FAILED! => {"changed": false, "msg": "Could not find or access 'standalone.sh'\nSearched in:\n\t/var/lib/awx/projects/_6__github_jhon/jboss/files/standalone.sh\n\t/var/lib/awx/projects/_6__github_jhon/jboss/standalone.sh\n\t/var/lib/awx/projects/_6__github_jhon/jboss/files/standalone.sh\n\t/var/lib/awx/projects/_6__github_jhon/jboss/standalone.sh on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}
24
...ignoring
25
26
TASK [Inicializa Servicio JBOSS 4.1] *******************************************
17:42:29
27
fatal: [vm_for_jboss]: FAILED! => {"changed": true, "cmd": "/home/jboss/jboss-6.4/bin/./standalone.sh", "delta": "0:00:00.036959", "end": "2019-02-22 17:45:48.668783", "msg": "non-zero return code", "rc": 127, "start": "2019-02-22 17:45:48.631824", "stderr": "/home/jboss/jboss-6.4/bin/./standalone.sh: line 306: java: command not found", "stderr_lines": ["/home/jboss/jboss-6.4/bin/./standalone.sh: line 306: java: command not found"], "stdout": "=========================================================================\n\n JBoss Bootstrap Environment\n\n JBOSS_HOME: /home/jboss/jboss-6.4\n\n JAVA: java\n\n JAVA_OPTS: -server -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true\n\n=========================================================================", "stdout_lines": ["=========================================================================", "", " JBoss Bootstrap E…
...
29
30
TASK [Inicializa Servicio JBOSS 4.1] *******************************************
17:42:29
31
fatal: [vm_for_jboss]: FAILED! => {"changed": true, "cmd": ["/home/jboss/jboss-6.4/bin/./standalone.sh"], "delta": "0:00:00.034198", "end": "2019-02-22 17:45:49.054563", "msg": "non-zero return code", "rc": 127, "start": "2019-02-22 17:45:49.020365", "stderr": "/home/jboss/jboss-6.4/bin/./standalone.sh: line 306: java: command not found", "stderr_lines": ["/home/jboss/jboss-6.4/bin/./standalone.sh: line 306: java: command not found"], "stdout": "=========================================================================\n\n JBoss Bootstrap Environment\n\n JBOSS_HOME: /home/jboss/jboss-6.4\n\n JAVA: java\n\n JAVA_OPTS: -server -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true\n\n=========================================================================", "stdout_lines": ["=========================================================================", "", " JBoss Bootstrap…
...
33
34
TASK [Inicializa Servicio JBOSS 5.1] *******************************************
17:42:29
35
fatal: [vm_for_jboss -> localhost]: FAILED! => {"changed": true, "cmd": ["sh", "/home/test_user/test.sh"], "delta": "0:00:00.391033", "end": "2019-02-22 20:42:30.439664", "msg": "non-zero return code", "rc": 127, "start": "2019-02-22 20:42:30.048631", "stderr": "sh: /home/test_user/test.sh: No such file or directory", "stderr_lines": ["sh: /home/test_user/test.sh: No such file or directory"], "stdout": "", "stdout_lines": []}
36
...ignoring
37
38
PLAY RECAP *********************************************************************
17:42:30
39
vm_for_jboss : ok=8 changed=5 unreachable=0 failed=0
40

Dick Visser

unread,
Feb 22, 2019, 4:19:46 PM2/22/19
to ansible...@googlegroups.com
I see a lot of "trial and error" attempts with command/shell, and with
errors ignored.
If I had to guess, those shell scripts rely on a number of environment
variables that aren't available to ansible.
This is a good start:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html
on how to set those.
> --
> 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/2630cc2f-2122-406a-ba2c-a7e17c1bf660%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Jhon J. Castro H.

unread,
Feb 25, 2019, 3:10:14 PM2/25/19
to Ansible Project

Thanks for you answer!

Effectively ansible did not get the environment variables from vm:

stdout Playbook:
"stdout": "=========================================================================\n\n
  JBoss Bootstrap Environment\n\n
    JBOSS_HOME: /home/jboss/jboss-6.4\n\n
    JAVA: java\n\n 
    JAVA_OPTS:  -server -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true\n\n
=========================================================================",
   
stdout from ./standalone.sh command:
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /home/jboss/jboss-6.4

  JAVA: /usr/java/jre-java/bin/java

  JAVA_OPTS:  -server -XX:+UseCompressedOops -verbose:gc -Xloggc:"/home/jboss/jboss-6.4/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true

=========================================================================

I resolved to manually set the environment variables and the shellscript file is execute correctly:
- name: Inicializa Servicio JBOSS
shell: sh /home/jboss/jboss-6.4/bin/standalone.sh
environment:
JAVA_HOME: /usr/java/jre-java
JAVA_OPTS: -server -XX:+UseCompressedOops -verbose:gc -Xloggc:"/home/jboss/jboss-6.4/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true


But the task remains running, does not move to the next task and I have to kill the task manually. The service stays running.




To proceed to the next task, try the following without success:

- name: Inicializa Servicio JBOSS
shell: sh /home/jboss/jboss-6.4/bin/standalone.sh > /dev/null &
environment:
JAVA_HOME: /usr/java/jre-java
JAVA_OPTS: -server -XX:+UseCompressedOops -verbose:gc -Xloggc:"/home/jboss/jboss-6.4/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true


When using the at module the desired result was obtained:
- at:
command: sh /home/jboss/jboss-6.4/bin/standalone.sh
count: 1
units: minutes
environment:
JAVA_HOME: /usr/java/jre-java
JAVA_OPTS: -server -XX:+UseCompressedOops -verbose:gc -Xloggc:"/home/jboss/jboss-6.4/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true

Reply all
Reply to author
Forward
0 new messages