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 - 

---
- hosts: 10.10.0.4
  become: yes
  tasks:
    - name: Run a script
      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 

 


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/60c1e3ed-ca83-45bc-ab46-cc2537271342%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to