# Not able to run the application from Ansible while same apps starts/stops from linux

**URL:** <https://forum.ansible.com/t/not-able-to-run-the-application-from-ansible-while-same-apps-starts-stops-from-linux/42532>\
**Category:** Get Help\
**Tags:** ansible-project\
**Created:** [May 8, 2025, 6:46am UTC](https://forum.ansible.com/t/not-able-to-run-the-application-from-ansible-while-same-apps-starts-stops-from-linux/42532 "2025-05-08T06:46:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish\_Gupta](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/manish_gupta/32/8372_2.png) [@Manish\_Gupta](https://forum.ansible.com/u/Manish_Gupta)\
**Post date:** [May 8, 2025, 6:46am UTC](https://forum.ansible.com/t/not-able-to-run-the-application-from-ansible-while-same-apps-starts-stops-from-linux/42532/1 "2025-05-08T06:46:26Z")

</div>

Hi There,  
We are trying to automate starting up and shutting down of Enovia application from Ansible. Enovia application runs on linux in our organizational environment.  
The good thing is that when we start Enovia directly from the server using unix shell command, this works but when we try starting the same application from ansible, it ends up with failure in starting up of the web GUI.

Observation:  
1) The application starts the JVM for 3dxspacenocas application but it dies after 30-40 seconds.  
2) The other application starts well which is 3dxfdsearch successfully.  
2) Ansible processes show that the application count increased intially but later the JVM process dies down.

I am not able to find out what is the exact issue.

Below please find attached the CODE which I have been using for your reference.

- my code

* * *

#This script starts the Enovia applications.  
#These applications include fdsearch, 3dspace, 3dspacenocas, 3dnotification, 3dswymn

# This script is calling some environment files and then the mail shell scripts which

# starts the Enovia application

# 

- name: Run shell script on managed host  
hosts: [3dxdap1.domain.com](http://3dxdap1.domain.com)  
gather\_facts: yes  
become: yes  
become\_user: mxvan  
vars:  
script\_path: “/opt/matrixone/tools/mms/matrix\_manage.sh”  
l\_action: “startall” # Change to “startall” or “stopall” as needed  
l\_env\_file\_1: “/home/matrixusers/mxvan/.profile”  
l\_env\_file\_2: “/home/matrixusers/mxvan/.bash\_profile”  
l\_environment: “3dvan” # Change to “integ”, “prod”, or other environments as needed  
ENV: “{{l\_environment}}”  
l\_env\_file: “/opt/matrixone/3dvan/r2023x/3dspace/scripts/mxEnv.sh”  
l\_cronprofile: “/home/matrixusers/mxvan/.cronprofile”  
DIR\_USER: “3dvan|mxvan|tomee\_3dpassport|tomee\_3dcomment|tomee\_3ddashboard|tomee\_3dfcs|tomee\_3dspace|tomee\_3dspacenocas|tomee\_3dfedsearch|tomee\_3dswym|latest|r2023x|1\n”  
WAR: “[3ddev|3dxdfcs1.domain.com|3dxddash2.domain.com|3dxdpass2.domain.com](http://3ddev%7C3dxdfcs1.domain.com%7C3dxddash2.domain.com%7C3dxdpass2.domain.com)\n [3dvan|3dxdfcs2.domain.com|3dxddash1.domain.com|3dxdpass1.domain.com](http://3dvan%7C3dxdfcs2.domain.com%7C3dxddash1.domain.com%7C3dxdpass1.domain.com)\n  
[3dinteg|3dxdfcs2.domain.com|3dxddash3.domain.com|3dxdpass3.domain.com](http://3dinteg%7C3dxdfcs2.domain.com%7C3dxddash3.domain.com%7C3dxdpass3.domain.com)\n [3dfulldev|3dxdfcs2.domain.com|3dxddash4.domain.com|3dxdpass4.domain.com](http://3dfulldev%7C3dxdfcs2.domain.com%7C3dxddash4.domain.com%7C3dxdpass4.domain.com)\n  
[3dbst|3dxdap2.domain.com|3dxdfcs3.bbn.domain.com|3dxdfcs1.domain.com|3dxddash5.domain.com|3dxdpass5.domain.com](http://3dbst%7C3dxdap2.domain.com%7C3dxdfcs3.bbn.domain.com%7C3dxdfcs1.domain.com%7C3dxddash5.domain.com%7C3dxdpass5.domain.com)\n [prod|3dxpap1.domain.com|3dxpap2.domain.com|3dxpfcos1.domain.com|3dxpfbbn1.bbn.domain.com|3dxpfhch1.hch.domain.com|3dxpfpng1.png.domain.com|3dxpfscs1.scs.domain.com|3dxpfsrs1.srs.domain.com|3dxpfsgp1.sgp.domain.com|3dxpfedi1.edi.domain.com|3dxpdash1.domain.com|3dxppass1.domain.com](http://prod%7C3dxpap1.domain.com%7C3dxpap2.domain.com%7C3dxpfcos1.domain.com%7C3dxpfbbn1.bbn.domain.com%7C3dxpfhch1.hch.domain.com%7C3dxpfpng1.png.domain.com%7C3dxpfscs1.scs.domain.com%7C3dxpfsrs1.srs.domain.com%7C3dxpfsgp1.sgp.domain.com%7C3dxpfedi1.edi.domain.com%7C3dxpdash1.domain.com%7C3dxppass1.domain.com)\n  
[dr|3dxdrdash1.dfw.domain.com|3dxdrpass1.dfw.domain.com|3dxdrex1.dfw.domain.com](http://dr%7C3dxdrdash1.dfw.domain.com%7C3dxdrpass1.dfw.domain.com%7C3dxdrex1.dfw.domain.com)\n”

---

<div class="post-metadata">

**Author:** ![wayt](https://avatars.discourse-cdn.com/v4/letter/w/3be4f8/32.png) [@wayt](https://forum.ansible.com/u/wayt)\
**Post date:** [May 8, 2025, 1:59pm UTC](https://forum.ansible.com/t/not-able-to-run-the-application-from-ansible-while-same-apps-starts-stops-from-linux/42532/2 "2025-05-08T13:59:39Z")

</div>

Is this application meant to stay running like a web server? If so, might I suggest crafting a systemd unit file for it and using ansible to start, stop, restart, etc the unit as required.

To elaborate, the command will try to capture stdout and stderr of the process and wait until the task timeout configuration setting. If it’s still running then it will interrupt the process. It’s possible with either command or shell, I’d have to test, to use nohup and sh -c while redirecting stdout and stderr away you might be able to get it to work. It’d definitely be a less preferable way over just configuring a systemd unit.

Even if you don’t have root you can use systemd user scoped units paired with lingering to get services that run regardless of a user being logged in.

---

<div class="post-metadata">

**Author:** ![iwt-cmd](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwt-cmd/32/9120_2.png) [@iwt-cmd](https://forum.ansible.com/u/iwt-cmd)\
**Post date:** [May 8, 2025, 2:54pm UTC](https://forum.ansible.com/t/not-able-to-run-the-application-from-ansible-while-same-apps-starts-stops-from-linux/42532/3 "2025-05-08T14:54:45Z")

</div>

I’ll second that a systemd unit file would seem to be the preferred way to go for this. The commands done in the Ansible shell module are tied to that shell process and die when the task is completed. Some users appear to have success with the “nohup” option, but, IMO, that is an unnecessary complication for something that a unit file is already designed to handle. You can also then use the Ansible systemd\_service module to manage starting and stopping the app in the future which is far less code and provides some built in state checking.

---

<div class="post-metadata">

**Author:** ![Manish\_Gupta](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/manish_gupta/32/8372_2.png) [@Manish\_Gupta](https://forum.ansible.com/u/Manish_Gupta)\
**Post date:** [May 12, 2025, 11:13am UTC](https://forum.ansible.com/t/not-able-to-run-the-application-from-ansible-while-same-apps-starts-stops-from-linux/42532/4 "2025-05-12T11:13:54Z")

</div>

Thanks for your time to go through this lengthy script. I worked with my unix admin and we observed that there was issue in doing become\_user throught sudo command. We could run the ansible script successfully after running the script directly from the user to which we were earlier planning to do become\_user. Anyway thanks for your help.
