1

I have a similar problem but my error message says:

{
"changed": false,
"msg": "Could not find or access 'woshutdown.sh'
Searched in: /var/ansible/tmp/awx_29146_42q4g5dt/project/qadeployment/files/woshutdown.sh
/var/ansible/tmp/awx_29146_42q4g5dt/project/qadeployment/woshutdown.sh
/var/ansible/tmp/awx_29146_42q4g5dt/project/qadeployment/files/woshutdown.sh
/var/ansible/tmp/awx_29146_42q4g5dt/project/qadeployment/woshutdown.sh on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option"
}

My script is call woshutdown.sh and it is meant call on another script that shuts down the remote server that it is located on. I have the shabang in the beginnig of the script but im getting that message.

This is my playbook: Playbook for the above task

This is where the script is located: Location of Script on remote server

I have tried Script Module I have tried CMD module and sh command. Please help!!

Martyn C
  • 1,109
  • 9
  • 18
  • 1
    Please don't post code snippets as images; it hinders legibility and makes them opaque to search engines -- it's explicitly mentioned in the [how to ask](https://stackoverflow.com/help/how-to-ask) page – mdaniel Aug 11 '20 at 20:51

1 Answers1

1

The current directory is never placed in the $PATH of a shell because it's a grave security risk. You'll want to specify the fully-qualified path to the script, which in your case, due to the chdir: is just ./:

- name: shutdown etc etc
  command: ./woshutdown.sh
  args:
    chdir: /methode/common/etc-etc-etc
mdaniel
  • 31,240
  • 5
  • 55
  • 58
  • Excellent It worked, I have received a changed value but the server still shows as on. When I executed the script manually It turns off the server but now when executed from tower it doesnt turn anything off on the remote host – Kyle Morton Aug 12 '20 at 14:46
  • You can try running the script in trace mode by `commend: bash -x ./woshutdown.sh` and see what assumption it is making, but beyond that no one on the Internet can magically guess what's wrong with your script – mdaniel Aug 12 '20 at 15:57