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 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: No such 
file or directory",

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

./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",
        "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",
        "control.postcodesio.nodejs.sh"
    ],
    "item": "dir_out.stdout_lines"
}

TASK start nodejs 
*****************************************************************************************************************************************
fatal: [hostname]: FAILED! => {"changed": true, "cmd": ["sh", "
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: No such file or directory", "stderr_lines": 
["sh: control.postcodesio.nodejs.sh: No such file or directory"], "stdout": 
"", "stdout_lines": []}



Any ideas much appreciated.


Reply all
Reply to author
Forward

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/a3021b2f-8e25-4233-bcd0-2fc171e71413n%40googlegroups.com.

Reply via email to