My sincere apologies for creating such a long thread - never my intention.  
I've received a lot of great help from this list, and don't want to 
jeopardize that.  As I mentioned earlier, I'm not always quick on the 
uptake. Thank you for sticking with me.  And, all of your effort have paid 
off, as I've come to the solution!  This is what my playbook looks like now:

---
> - hosts: all
>   gather_facts: false
>   become: yes
>   become_method: su
>   become_flags: '-'
>   vars:
>     ansible_become_pass: "rootpass"
>   tasks:
>     - shell: /scripts/dnscopy.pl -f
>       register: script_output
>     - debug:
>         var: script_output.stdout_lines


It returns the same output as if I ran the script on the remote host:

TASK [command] 
> ****************************************************************
> task path: /etc/ansible/playbooks/rundeck/dnscopy.yml:13
> Using module file 
> /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
> <admin1> ESTABLISH SSH CONNECTION FOR USER: a-scripting
> <admin1> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o 
> ControlPersist=60s -o StrictHostKeyChecking=no -o User=a-scripting -o 
> ConnectTimeout=300 -o ControlPath=/root/.ansible/cp/00d0d0be4b admin1 
> '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
> <admin1> (0, '/home/a-scripting\n', '')
> <admin1> ESTABLISH SSH CONNECTION FOR USER: a-scripting
> <admin1> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o 
> ControlPersist=60s -o StrictHostKeyChecking=no -o User=a-scripting -o 
> ConnectTimeout=300 -o ControlPath=/root/.ansible/cp/00d0d0be4b admin1 
> '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073 `" 
> && echo ansible-tmp-1544020870.43-70326662458073="` echo 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073 `" 
> ) && sleep 0'"'"''
> <admin1> (0, 
> 'ansible-tmp-1544020870.43-70326662458073=/home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073\n',
>  
> '')
> <admin1> PUT /tmp/tmpKrQPZW TO 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073/command.py
> <admin1> SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -o 
> ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 
> User=a-scripting -o ConnectTimeout=300 -o 
> ControlPath=/root/.ansible/cp/00d0d0be4b '[admin1]'
> <admin1> (0, 'sftp> put /tmp/tmpKrQPZW 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073/command.py\n',
>  
> '')
> <admin1> ESTABLISH SSH CONNECTION FOR USER: a-scripting
> <admin1> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o 
> ControlPersist=60s -o StrictHostKeyChecking=no -o User=a-scripting -o 
> ConnectTimeout=300 -o ControlPath=/root/.ansible/cp/00d0d0be4b admin1 
> '/bin/sh -c '"'"'chmod u+x 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073/ 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073/command.py
>  
> && sleep 0'"'"''
> <admin1> (0, '', '')
> <admin1> ESTABLISH SSH CONNECTION FOR USER: a-scripting
> <admin1> SSH: EXEC sshpass -d12 ssh -C -o ControlMaster=auto -o 
> ControlPersist=60s -o StrictHostKeyChecking=no -o User=a-scripting -o 
> ConnectTimeout=300 -o ControlPath=/root/.ansible/cp/00d0d0be4b -tt admin1 
> '/bin/sh -c '"'"'su - root -c '"'"'"'"'"'"'"'"'/bin/sh -c 
> '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'echo 
> BECOME-SUCCESS-ekoalvjsxgctatfhsngmjohojiatrsbx; /usr/bin/python 
> /home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073/command.py;
>  
> rm -rf 
> "/home/a-scripting/.ansible/tmp/ansible-tmp-1544020870.43-70326662458073/" 
> > /dev/null 
> 2>&1'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"' 
> && sleep 0'"'"''
> <admin1> (0, '\r\n\r\n{"changed": true, "end": "2018-12-05 
> 09:41:14.641125", "stdout": "server reload successful\\nserver reload 
> successful\\nserver reload successful\\nserver reload successful", "cmd": 
> "/scripts/dnscopy.pl -f", "rc": 0, "start": "2018-12-05 09:41:10.058261", 
> "stderr": "", "delta": "0:00:04.582864", "invocation": {"module_args": 
> {"warn": true, "executable": null, "_uses_shell": true, "_raw_params": 
> "/scripts/dnscopy.pl -f", "removes": null, "creates": null, "chdir": 
> null}}, "warnings": []}\r\n', 'Shared connection to admin1 closed.\r\n')
> changed: [admin1] => {
>     "changed": true, 
>     "cmd": "/scripts/dnscopy.pl -f", 
>     "delta": "0:00:04.582864", 
>     "end": "2018-12-05 09:41:14.641125", 
>     "invocation": {
>         "module_args": {
>             "_raw_params": "/scripts/dnscopy.pl -f", 
>             "_uses_shell": true, 
>             "chdir": null, 
>             "creates": null, 
>             "executable": null, 
>             "removes": null, 
>             "warn": true
>         }
>     }, 
>     "rc": 0, 
>     "start": "2018-12-05 09:41:10.058261"
> }
> STDOUT:
>
>
>
> *server reload successfulserver reload successfulserver reload 
> successfulserver reload successful*
>
> TASK [debug] 
> ****************************************************************
> task path: /etc/ansible/playbooks/rundeck/dnscopy.yml:15
> ok: [admin1] => {
>     "script_output.stdout_lines": [
>
>
>
> *        "server reload successful",         "server reload successful",   
>       "server reload successful",         "server reload successful"*
>     ]
> }


I'm very grateful to Piotr and Kai for their kind and expert assistance!!!  
Thank you so much.

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/ffe23f24-110a-46d8-80d3-5e2be52857d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to