# error run shell script for start service jboss

**URL:** <https://forum.ansible.com/t/error-run-shell-script-for-start-service-jboss/29748>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [February 22, 2019, 8:59pm UTC](https://forum.ansible.com/t/error-run-shell-script-for-start-service-jboss/29748 "2019-02-22T20:59:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jhon\_J\_Castro\_H](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@Jhon\_J\_Castro\_H](https://forum.ansible.com/u/Jhon_J_Castro_H)\
**Post date:** [February 22, 2019, 8:59pm UTC](https://forum.ansible.com/t/error-run-shell-script-for-start-service-jboss/29748/1 "2019-02-22T20:59:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 22, 2019, 9:19pm UTC](https://forum.ansible.com/t/error-run-shell-script-for-start-service-jboss/29748/2 "2019-02-22T21:19:25Z")

</div>

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](https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html)  
on how to set those.

---

<div class="post-metadata">

**Author:** ![Jhon\_J\_Castro\_H](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@Jhon\_J\_Castro\_H](https://forum.ansible.com/u/Jhon_J_Castro_H)\
**Post date:** [February 25, 2019, 8:10pm UTC](https://forum.ansible.com/t/error-run-shell-script-for-start-service-jboss/29748/3 "2019-02-25T20:10:14Z")

</div>

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:**

> **(attachments)**
>
> ![Auto Generated Inline Image 1.png](https://us1.discourse-cdn.com/ansible/original/2X/d/d49e3a204ecbc1127d35c85ea17b1825ef0359b8.png)
