error run shell script for start service jboss

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

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.

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)