Dear Ansiblists,

I have written a tool that wraps ansible-playbook to enforce a client's 
fairly complex workflow and provides helper functions specific to their use 
case. The only thing that I lose by doing is the colorized output. Is there 
anyway I can trick ansible-playbook and other commands to output colorized 
output?


I use this invocation of subprocess.Popen to spawn the ansible playbook and 
flush the stdout

 p = subprocess.Popen('ansible-playbook . . . ', stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, shell=True) 
 flush_subprocess_stdout(p.stdout)

# this function is located elsewhere
def flush_subprocess_stdout(stdout_fd):
  lines = []
  while True:
    line = stdout_fd.readline()
    if not line:
      break
    lines.append(line)
    print line.strip()
  return lines

I found these lines in ansible-playbook, which appear to determine what 
output is colorized and which is not. I also looked at the display method 
in ansible.callbacks. It's still not clear to me how I can convince 
ansible-playbook to colorize stdout.  Any suggestions?

https://github.com/ansible/ansible/blob/devel/bin/ansible-playbook#L287-L303

Bryan

-- 
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/d7c1b914-c464-4bbf-a331-80151524897e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to