Hello,

I'm trying to execute a remote python script on linux nodes.
So, the first step  I do is to copy the script file in the remote nodes 
with the "copy" module and this works well:

root@soporte03:# ansible sura -m copy -a "src=/root/passwd.py 
dest=/home/AdminSplunk/ owner=AdminSplunk group=AdminSplunk mode=0777"


The correct way to execute the script in a server without use ansible is 
this:

python passwd.py "current-password" "new-password"

My problem is when I try to execute this script in the ansible nodes, I ran 
this line with several modules ansible but continues to generate errors
This are the lines that i used using ansible

--------------- With the script module ---------------

root@soporte03:/etc/ansible # ansible sura  -m script -a "python passwd.py 
'Suramericana.2016*' 'Su334N..103'"
micha2 | FAILED! => {
    "failed": true, 
    "msg": "file or module does not exist: /etc/ansible/python"
}
micha1 | FAILED! => {
    "failed": true, 
    "msg": "file or module does not exist: /etc/ansible/python"
}


--------------- With the shell module ---------------

root@soporte03:/etc/ansible # ansible sura  -m shell -a "python passwd.py 
'Suramericana.2016*' 'Su334N..103'"
micha2 | FAILED | rc=1 >>
Changing user password
Cambiando la contraseña del usuario AdminSplunk.
Cambiando la contraseña de AdminSplunk.
(actual) contraseña de UNIX: Traceback (most recent call last):
  File "passwd.py", line 13, in <module>
    current = p.expect('\(current\) UNIX password:', timeout=3)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1311, in expect
    return self.expect_list(compiled_pattern_list, timeout, 
searchwindowsize)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1325, in 
expect_list
    return self.expect_loop(searcher_re(pattern_list), timeout, 
searchwindowsize)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1409, in 
expect_loop
    raise TIMEOUT (str(e) + '\n' + str(self))
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
<pexpect.spawn object at 0x7fce82a25690>
version: 2.3 ($Revision: 399 $)
command: /usr/bin/passwd
args: ['/usr/bin/passwd']
searcher: searcher_re:
    0: re.compile("\(current\) UNIX password:")
buffer (last 100 chars): a del usuario AdminSplunk.
Cambiando la contraseña de AdminSplunk.
(actual) contraseña de UNIX: 
before (last 100 chars): a del usuario AdminSplunk.
Cambiando la contraseña de AdminSplunk.
(actual) contraseña de UNIX: 
after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 1838
child_fd: 3
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: <open file '<stdout>', mode 'w' at 0x7fce82b0c150>
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1


--------------- With the raw module ---------------

root@soporte03:/etc/ansible # ansible sura  -m raw -a "python passwd.py 
'Suramericana.2016*' 'Su334N..103'"
micha1 | FAILED | rc=1 >>
Changing user password
Cambiando la contraseña del usuario AdminSplunk.
Cambiando la contraseña de AdminSplunk.
(actual) contraseña de UNIX: Traceback (most recent call last):
  File "passwd.py", line 13, in <module>
    current = p.expect('\(current\) UNIX password:', timeout=3)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1311, in expect
    return self.expect_list(compiled_pattern_list, timeout, 
searchwindowsize)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1325, in 
expect_list
    return self.expect_loop(searcher_re(pattern_list), timeout, 
searchwindowsize)
  File "/usr/lib/python2.6/site-packages/pexpect.py", line 1409, in 
expect_loop
    raise TIMEOUT (str(e) + '\n' + str(self))
pexpect.TIMEOUT: Timeout exceeded in read_nonblocking().
<pexpect.spawn object at 0x7fb6c7847610>
version: 2.3 ($Revision: 399 $)
command: /usr/bin/passwd
args: ['/usr/bin/passwd']
searcher: searcher_re:
    0: re.compile("\(current\) UNIX password:")
buffer (last 100 chars): a del usuario AdminSplunk.
Cambiando la contraseña de AdminSplunk.
(actual) contraseña de UNIX: 
before (last 100 chars): a del usuario AdminSplunk.
Cambiando la contraseña de AdminSplunk.
(actual) contraseña de UNIX: 
after: <class 'pexpect.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 1720
child_fd: 3
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: <open file '<stdout>', mode 'w' at 0x7fb6c792f150>
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1

please someone tell me what is the correct way to execute a remote python 
script with ansible.

Appreciate your help.

-- 
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/abbf2781-e591-469c-9bdd-7c24a373c687%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to