On Wednesday, 5 December 2018 16:02:03 CET Dimitri Yioulos wrote:
> 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.
No worry, you haven't.
My mail was about you to provide more information, I could have left out the
"long thread" in my reply, but I didn't since you/we where back to the stating
point.
> 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
So it was just about missing password.
(The fun thing is that if you had provided complete output, as you did in this
post, in your first post I guessing you had gotten an answer the same day.
But no harm done, since you have a working solution.)
> 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"*
> > ]
> > }
This output is a huge help for us to help you when you have problem.
Keep that in mind next time you have a problem you need help with.
-vvvv is not need all the time, but are you unsure it's better to include it
that not.
--
Kai Stian Olstad
--
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/2407891.dbGre87DWr%40x1.
For more options, visit https://groups.google.com/d/optout.