OK:

---
> - hosts: all
>   gather_facts: false
>   become: yes
> #  become_user: root
> #  become_method: su
>   tasks:
>     - shell: "su - root"
>       args:
>         warn: false
>     - shell: '/scripts/dnscopy.pl -f'
>       register: (result)
>     - debug:
>         var: (result)
>         verbosity: 2


*become_user and become_method are commented out in favor of shell: "su - 
root" because using the former causes a timeout error, But that's another 
issue.

Output of play:

TASK [command] 
***************************************************************************************************************************************************************************
fatal: [admin1]: FAILED! => {"changed": true, "cmd": "/scripts/dnscopy.pl 
-f", "delta": "0:00:01.425695", "end": "2018-12-03 17:13:56.113927", 
"failed": true, "rc": 2, "start": "2018-12-03 17:13:54.688232", "stderr": 
"Can't exec \"rndc\": No such file or directory at /scripts/dnscopy.pl line 
296.\nrndc -s dns1 reload failed: No such file or directory at 
/scripts/dnscopy.pl line 296.", "stderr_lines": ["Can't exec \"rndc\": No 
such file or directory at /scripts/dnscopy.pl line 296.", "rndc -s dns1 
reload failed: No such file or directory at /scripts/dnscopy.pl line 
296."], "stdout": "", "stdout_lines": []}

without the -f switch, the play completes successfully.


On Monday, December 3, 2018 at 11:44:08 AM UTC-5, Dimitri Yioulos wrote:
>
> Hey, all.
>
> I need to run a script residing on the remote machine with a switch, as in 
> "/scripts/myscript -f" (it must be executed by root).  I'm using the shell 
> module, but can find no way to add the switch without the play failing.  
> Help would be appreciated.
>
> Dimitri
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ef043055-1226-4a41-862f-2a3c66097b4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to