Re: [ansible-project] Running simple ad hoc commands via script module not working

2017-09-08 Thread Anfield
No specific requirement. I just wanted to bundle up some ad hoc commands 
and run them via script module.

You are correct. I just recently setup that 2nd vm and didnt have ansible 
installed. Fixed that. Now the command runs but doesnt actually create the 
file, even though the output reports changed..

Any idea why that would be? Doesnt seem to do anything when pointed to tmp 
either

[ansible@localhost playbooks]$ ansible-playbook scriptcall.yml

PLAY [10.10.0.4] 
***

TASK [Gathering Facts] 
*
ok: [10.10.0.4]

TASK [Run a script] 

changed: [10.10.0.4]

PLAY RECAP 
*
10.10.0.4  : ok=2changed=1unreachable=0failed=0




>

-- 
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/3b6cfc66-e1ff-4a7e-ad76-631d864044f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Running simple ad hoc commands via script module not working

2017-09-08 Thread Jean-Yves LENHOF


Le 08/09/2017 à 18:22, Anfield a écrit :
> 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

Don't really understand what you're going to do... but the script works,
it justs does'nt find ansible installed on your remote server
Perhaps you should explain what you want to do before mixing playbook
and had hoc command

Regards,

JYL

-- 
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/b094456d-c112-6d7d-2196-0ca9b3985f8b%40lenhof.eu.org.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Running simple ad hoc commands via script module not working

2017-09-08 Thread Anfield
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.