Hello all,

I am using ansible to deploy and provision some instances then runs a 
python script at the very end. The python script uses the subprocess module 
<https://docs.python.org/2/library/subprocess.html#popen-constructor> to 
call a sql script and generate flat text files. When I directly ssh into 
the instances and run remotely, everything works. However when I use 
ansible to call the python script it looks like commands don't get passed 
to the Popen construct OR sqlplus is not installed??? Which is weird cause 
it definitely is installed. This may be a more python oriented question but 
since I only have the issue when using Ansible to run the python program... 
I'm posting here. 

Ansible: 
ansible webservers -i inventory --vault-password-file ~/.vault_pass.txt -u 
ec2-user -m command -a "python script.py chdir=dir/dir1/dir2"

Python:
connect_string=username/password@connectionObject
sql_command=@sql_script.sql

def run_sql_query(sql_command, connect_string):
  """
  Run sqlCommand and return query result and error Message
  """
  session = Popen(['sqlplus', '-S', connect_string], stdin=PIPE, 
stdout=PIPE, stderr=PIPE)
  session.stdin.write(sql_command)
  return session.communicate()

Error:
  File "/usr/lib64/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

A closer look shows that one of the following is happening:

1) /bin/bash: sqlplus: command not found
 
HOW???

-- 
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/32c1644a-88ef-4f23-9aa2-578a378789ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to