I have a playbook and a script file which contains a couple of simple ad hoc commands, but it is not working.
I have 2 VMs on my desktop which are linked up via custom host-only 10.10.x.x network. Connection is working, other playbooks work fine etc.
Playbook -
script: /etc/ansible/playbooks/script.sh
Script.sh
[ansible@localhost playbooks]$ vi script.sh
#!/bin/bash
ansible 10.10.0.4 -m file -a "path=/home/ansible/newfile2.txt state=touch"
Output -
TASK [Run a script] ****************************************************************************************************
fatal: [10.10.0.4]: FAILED! => {"changed": true, "failed": true, "rc": 127, "stderr": "Shared connection to 10.10.0.4 closed.\r\n", "stdout": "/home/ansible/.ansible/tmp/ansible-tmp-1504887533.6-234169887879143/script.sh: line 3: ansible: command not found\r\n", "stdout_lines": ["/home/ansible/.ansible/tmp/ansible-tmp-1504887533.6-234169887879143/script.sh: line 3: ansible: command not found"]}
Any idea? Am i missing something? Thanks