# Unable to start JBoss EAP using ansible

**URL:** <https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [July 18, 2018, 3:37am UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075 "2018-07-18T03:37:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shankar\_Shiva](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Shankar\_Shiva](https://forum.ansible.com/u/Shankar_Shiva)\
**Post date:** [July 18, 2018, 3:37am UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/1 "2018-07-18T03:37:03Z")

</div>

Hi,

I had created below ansible structure :

-rw-rw-r-- 1 packt packt 1841 Jun 3 18:36 [README.md](https://readme.md/) -rw-rw-r-- 1 packt packt 217 Jun 3 18:36 [LICENSE.md](https://license.md/) -rw-rw-r-- 1 packt packt 123 Jul 12 17:57 ansible.cfg -rw-rw-r-- 1 packt packt 103 Jul 12 17:58 site.yml drwxrwxr-x 2 packt packt 4096 Jul 13 05:05 group\_vars drwxrwxr-x 4 packt packt 4096 Jul 13 05:06 roles -rw-rw-r-- 1 packt packt 428 Jul 17 05:23 inventory

Below is my main.yml under roles/jboss/

— - name: For ubuntu download the JDK1.7, Jboss software get\_url: url=[https://s3.ap-south-1.amazonaws.com/shivasoftware/{](https://s3.ap-south-1.amazonaws.com/shivasoftware/%7B)‌{item}} dest=/home/packt mode=0755 with\_items: - eap64.tar.gz - jdk-7u80-linux-x64.tar.gz

- name: extract the JDK Software command: chdir=/home/packt /bin/tar -xvf /home/packt/{‌{item}} with\_items: - eap64.tar.gz - jdk-7u80-linux-x64.tar.gz

- name: setting JAVA\_HOME after taking the backkup of .bashrc blockinfile: path: /home/packt/.bashrc block: | export JAVA\_HOME=/home/packt/jdk1.7.0\_80 export PATH=$JAVA\_HOME/bin:$PATH insertafter: EOF backup: yes # become: yes

- name: source bashrc shell: . /home/packt/.bashrc register: home\_java

- name: start JBoss command: /home/packt/EAP-6.4.0/bin/standalone.sh # when: echo JAVA\_HOME != /home/packt/jdk1.7.0\_80 when: home\_java.stdout.find(‘java’) == -1 When i’m executing the playbook I’m getting the below issue:

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: [ubuntu3]

TASK [ubuntu : For ubuntu download the JDK1.7, Jboss software] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: [ubuntu3] =\> (item=eap64.tar.gz) ok: [ubuntu3] =\> (item=jdk-7u80-linux-x64.tar.gz)

TASK [ubuntu : extract the JDK Software] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* changed: [ubuntu3] =\> (item=eap64.tar.gz) changed: [ubuntu3] =\> (item=jdk-7u80-linux-x64.tar.gz)

TASK [ubuntu : setting JAVA\_HOME after taking the backkup of .bashrc] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ok: [ubuntu3]

TASK [ubuntu : source bashrc] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* changed: [ubuntu3]

TASK [ubuntu : start JBoss] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* fatal: [ubuntu3]: FAILED! =\> {“changed”: true, “cmd”: [“/home/packt/EAP-6.4.0/bin/standalone.sh”], “delta”: “0:00:00.277796”, “end”: “2018-07-17 06:06:42.393817”, “msg”: “non-zero return code”, “rc”: 127, “start”: “2018-07-17 06:06:42.116021”, “stderr”: “/home/packt/EAP-6.4.0/bin/standalone.sh: 1: eval: java: not found”, “stderr\_lines”: [“/home/packt/EAP-6.4.0/bin/standalone.sh: 1: eval: java: not found”], “stdout”: “=========================================================================\n\n JBoss Bootstrap Environment\n\n JBOSS\_HOME: /home/packt/EAP-6.4.0\n\n JAVA: java\n\n JAVA\_OPTS: -server -Xms1303m -Xmx1303m -XX:MaxPermSize=256m [-Djava.net](https://-djava.net/).preferIPv4Stack=false [-Djava.net](https://-djava.net/).preferIPv6Addresses=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true\n\n=========================================================================”, “stdout\_lines”: [“=========================================================================”, “”, " JBoss Bootstrap Environment", “”, " JBOSS\_HOME: /home/packt/EAP-6.4.0", “”, " JAVA: java", “”, " JAVA\_OPTS: -server -Xms1303m -Xmx1303m -XX:MaxPermSize=256m [-Djava.net](https://-djava.net/).preferIPv4Stack=false [-Djava.net](https://-djava.net/).preferIPv6Addresses=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.modules.policy-permissions=true", “”, “=========================================================================”]} to retry, use: --limit @/home/packt/ansible/site.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* ubuntu3 : ok=5 changed=2 unreachable=0 failed=1

Can you help me to resolve the issue??

When I was checking in client machine,

1. which java gave me below response: /home/packt/jdk1.7.0\_80/bin/java

2. structure created on target machine:

drwxr-xr-x 8 packt packt 4096 Apr 11 2015 jdk1.7.0\_80 -rw-r–r-- 1 packt packt 220 Nov 14 2017 .bash\_logout drwxr-xr-x 3 root root 4096 Nov 14 2017 … -rw-r–r-- 1 packt packt 655 Nov 14 2017 .profile drwx------ 2 packt packt 4096 Nov 14 2017 .cache -rw-r–r-- 1 packt packt 0 Nov 14 2017 .sudo\_as\_admin\_successful drwx------ 2 packt packt 4096 Jul 14 04:40 .ssh -rw------- 1 packt packt 0 Jul 17 03:40 .bash\_history drwx------ 3 packt packt 4096 Jul 17 03:47 .ansible -rwxr-xr-x 1 packt packt 3771 Jul 17 05:00 .bashrc.2588.2018-07-17@05:02:12~ -rwxr-xr-x 1 packt packt 3903 Jul 17 05:02 .bashrc.3982.2018-07-17@05:36:18~ -rwxr-xr-x 1 packt packt 3907 Jul 17 05:36 .bashrc.4253.2018-07-17@05:42:37~ -rw------- 1 packt packt 3368 Jul 17 05:38 .viminfo -rwxr-xr-x 1 packt packt 3903 Jul 17 05:42 .bashrc -rw-rw-r-- 1 packt packt 173414400 Jul 17 05:42 eap.tar -rwxr-xr-x 1 packt packt 153530841 Jul 17 05:45 jdk-7u80-linux-x64.tar.gz -rwxr-xr-x 1 packt packt 151761793 Jul 17 05:47 eap64.tar.gz drwxr-xr-x 7 packt packt 4096 Jul 17 05:48 . drwxrwxr-x 13 packt packt 4096 Jul 17 06:06 EAP-6.4.0

---

<div class="post-metadata">

**Author:** ![Daria\_Serkova](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@Daria\_Serkova](https://forum.ansible.com/u/Daria_Serkova)\
**Post date:** [July 18, 2018, 9:17am UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/2 "2018-07-18T09:17:25Z")

</div>

Hi, Shankar Shiva  
Can you make correct formating?  
Not sure what did you mean here - " when: echo JAVA\_HOME != /home/packt/jdk1.7.0\_80 when: home\_java.stdout.find(‘java’) == -1"

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [July 18, 2018, 12:44pm UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/3 "2018-07-18T12:44:12Z")

</div>

Hmm, by the look of things you are trying to use ‘command’ to actually start jboss.

This is unlikely to work well as you have no shell when using ‘command’, meaning no shell features like environment varirables or \> or &

You can try and use ‘environment’ keyword to specify exact environment variables you need to run the command (see [https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_environment.html?highlight=environment#working-with-language-specific-version-managers](https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html?highlight=environment#working-with-language-specific-version-managers) for examples) , but I think you will wind up with more readable playbooks if you create a service script to run jboss.

The service script can su to the correct user and set up any environment variables that jboss needs before starting the java command line.

Then, once you have a service set up you can use service module to start stop jboss. All the complexity of starting up jboss is hidden away in the service startup script and your playbooks intentions become easier to understand.

Hope this helps,

Jon

---

<div class="post-metadata">

**Author:** ![Shankar\_Shiva](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Shankar\_Shiva](https://forum.ansible.com/u/Shankar_Shiva)\
**Post date:** [July 18, 2018, 5:48pm UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/4 "2018-07-18T17:48:45Z")

</div>

> Hi,  
> Thanks for your reply. Below is reconstructed problem statement. Also, PFA  
> files I used
> 
> Problem Statement:  
> I'm using ansible roles to install and start JBoss EAP 6.4 version. As  
> part of this:  
> 1) I'm downloading and extracting the JDK and EAP.tar.gz from S3  
> 2) Once done I'm updating the JDK in user profile folder for setting tehe  
> class path  
> 3) Lastly starting the jboss application server
> 
> But, I'm getting the below exception when running the playbook:  
> FAILED! =\> {"changed": true, "cmd":  
> ["/home/packt/EAP-6.4.0/bin/standalone.sh"], "delta": "0:00:00.277796",  
> "end": "2018-07-17 06:06:42.393817", "msg": "non-zero return code", "rc":  
> 127, "start": "2018-07-17 06:06:42.116021", "stderr":  
> "/home/packt/EAP-6.4.0/bin/standalone.sh: 1: eval: java: not found",  
> "stderr\_lines": ["/home/packt/EAP-6.4.0/bin/standalone.sh: 1: eval: java:  
> not found"], "stdout":  
> "=========================================================================\n\n  
> JBoss Bootstrap Environment\n\n JBOSS\_HOME: /home/packt/EAP-6.4.0\n\n  
> JAVA: java\n\n JAVA\_OPTS: -server -Xms1303m -Xmx1303m  
> -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=false  
> -Djava.net.preferIPv6Addresses=true  
> -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true  
> -Djboss.modules.policy-permissions=true\n\n=========================================================================",  
> "stdout\_lines":  
> ["=========================================================================",  
> "", " JBoss Bootstrap Environment", "", " JBOSS\_HOME:  
> /home/packt/EAP-6.4.0", "", " JAVA: java", "", " JAVA\_OPTS: -server  
> -Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=false  
> -Djava.net.preferIPv6Addresses=true  
> -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true  
> -Djboss.modules.policy-permissions=true", "",  
> "========================================================================="]}  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to retry, use: --limit @/home/packt/ansible/site.retry
> 
> But, on the client machine when I start the JBoss application server I'm  
> able to start and not getting the exception.

Thanks and Regards,  
Shankar

> **(attachments)**
>
> [ansible.zip](https://forum.ansible.com/uploads/short-url/kjukBxSIlZZOGMyay4z5VVDddbj.zip) (4.34 KB)

---

<div class="post-metadata">

**Author:** ![Daria\_Serkova](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@Daria\_Serkova](https://forum.ansible.com/u/Daria_Serkova)\
**Post date:** [July 19, 2018, 8:06am UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/5 "2018-07-19T08:06:56Z")

</div>

Hi,  
Now it’s more clear 🙂  
ansible/roles/ubuntu/tasks/main.yml

- name: start JBoss  
command: **source /home/packt/.bashrc;** /home/packt/EAP-6.4.0/bin/domain.sh

Try this way.  
In your variant you just launch bashrc in one process and then launch jboss in the other. But the processes are different, and one can’t access the variables from another.

ср, 18 июл. 2018 г. в 20:48, Shankar Shiva \<[mailnsa@gmail.com](mailto:mailnsa@gmail.com)\>:

---

<div class="post-metadata">

**Author:** ![Shankar\_Shiva](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@Shankar\_Shiva](https://forum.ansible.com/u/Shankar_Shiva)\
**Post date:** [July 19, 2018, 11:09am UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/6 "2018-07-19T11:09:41Z")

</div>

Tried but no luck 😒

---

<div class="post-metadata">

**Author:** ![Daria\_Serkova](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@Daria\_Serkova](https://forum.ansible.com/u/Daria_Serkova)\
**Post date:** [July 19, 2018, 2:13pm UTC](https://forum.ansible.com/t/unable-to-start-jboss-eap-using-ansible/28075/7 "2018-07-19T14:13:27Z")

</div>

ok, and what if specify the variable in command module itself?  
command: /home/packt/EAP-6.4.0/bin/domain.sh

environment:

JAVA\_HOME: …

(see here - [https://docs.ansible.com/ansible/2.6/user\_guide/playbooks\_environment.html](https://docs.ansible.com/ansible/2.6/user_guide/playbooks_environment.html))

чт, 19 июл. 2018 г. в 14:09, Shankar Shiva \<[mailnsa@gmail.com](mailto:mailnsa@gmail.com)\>:
