# Ansible task not starting up custom node.js script with either shell or command module

**URL:** <https://forum.ansible.com/t/ansible-task-not-starting-up-custom-node-js-script-with-either-shell-or-command-module/33730>\
**Category:** Ansible Developer\
**Created:** [September 2, 2020, 7:49pm UTC](https://forum.ansible.com/t/ansible-task-not-starting-up-custom-node-js-script-with-either-shell-or-command-module/33730 "2020-09-02T19:49:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonin](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jonin](https://forum.ansible.com/u/Jonin)\
**Post date:** [September 2, 2020, 7:49pm UTC](https://forum.ansible.com/t/ansible-task-not-starting-up-custom-node-js-script-with-either-shell-or-command-module/33730/1 "2020-09-02T19:49:48Z")

</div>

Hi,

Any ideas where I am going wrong here?

I have a web server task which uses shell to start apache no problem:

- hosts: webservers  
remote\_user: root  
become\_user: test  
become: True  
tasks:
- name: Task18 - Start webservers back up  
shell: ./apache/bin/apachectl start  
tags:
- startweb

I have made a similar task to try start node for which I pass in the same ‘start’ arguement

- hosts: nodes  
remote\_user: root  
become\_user: test  
become: True  
tasks:
- name: Start node back up  
shell: ./_ **/** _/init.d/etc.d/[control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/) start  
tags:
- startnode

This task fails with :

“msg”: “non-zero return code”, “rc”: 127, “start”: “2020-09-02 19:07:49.395993”, “stderr”: “sh: [control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/): No such file or directory”,

This script definitely exists in this location and works if triggered manually:

./[control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/) start  
Starting NodeJS: 26182  
NodeJS instance running

I have tried a different approach but I still get the same No such file or directory

tasks:

- name: Change Directory  
command: cd /_ **/** _/init.d/etc.d/

- command: “ls /_ **/** _/init.d/etc.d/”  
register: dir\_out

- debug: var={{item}}  
with\_items: dir\_out.stdout\_lines

- name: start nodejs  
command: sh control.postcodesio.nodejs.sh start

The output of the debug step above confirms the presence of the script as shown in the output below so i really don’t understand why it says the “control.postcodesio.nodejs.sh” can’t be found?

:

TASK Change Directory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [hostname]  
changed: [[h](http://vm019742.bskyb.com/)ostname]

TASK [command] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [hostname]  
changed: [hostname]

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [hostname] =\> (item=dir\_out.stdout\_lines) =\> {  
“changed”: false,  
“dir\_out.stdout\_lines”: [  
“[control.apache.sh](http://control.apache.sh/)”,  
“[control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/)”  
],  
“item”: “dir\_out.stdout\_lines”  
}  
ok: [hostname] =\> (item=dir\_out.stdout\_lines) =\> {  
“changed”: false,  
“dir\_out.stdout\_lines”: [  
“[control.apache.sh](http://control.apache.sh/)”,  
“[control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/)”  
],  
“item”: “dir\_out.stdout\_lines”  
}

TASK start nodejs \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [hostname]: FAILED! =\> {“changed”: true, “cmd”: [“sh”, “[control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/)”, “start”], “delta”: “0:00:00.007772”, “end”: “2020-09-02 19:07:49.098795”, “msg”: “non-zero return code”, “rc”: 127, “start”: “2020-09-02 19:07:49.091023”, “stderr”: “sh: [control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/): No such file or directory”, “stderr\_lines”: [“sh: [control.postcodesio.nodejs.sh](http://control.postcodesio.nodejs.sh/): No such file or directory”], “stdout”: “”, “stdout\_lines”: }

Any ideas much appreciated.

Reply all

Reply to author

Forward

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 2, 2020, 8:06pm UTC](https://forum.ansible.com/t/ansible-task-not-starting-up-custom-node-js-script-with-either-shell-or-command-module/33730/2 "2020-09-02T20:06:18Z")

</div>

Hi,

you might want to ask this in the appropriate places, for example  
[https://groups.google.com/forum/#!topic/ansible-project/](https://groups.google.com/forum/#!topic/ansible-project/)

This mailing list / group is about discussing developing Ansible, and  
not for support questions.

Thanks,  
Felix Fontein
