Force color output?

1,605 views
Skip to first unread message

Jason Harris

unread,
Sep 16, 2014, 5:29:14 PM9/16/14
to ansible...@googlegroups.com
Hi All,

I am trying to capture ansible output with a python subprocess command. If I capture:

childProcess = subprocess.Popen("ansible-playbook ...", shell=True, subprocess.PIPE, subprocess.PIPE, cwd=dir)
res = childProcess.communicate()

Then res[0] will be the stdout of my ansible command, and res[1] will be the stderr of my ansible command, but both will be uncoloured...

Is there an easy way to force ansible to always issue colour output independent of the term type it is detecting?

Thanks,
   Jason

Matt Martz

unread,
Sep 16, 2014, 6:01:47 PM9/16/14
to ansible...@googlegroups.com
I actually just submitted a pull request to document the configuration to allow this earlier today.

It looks like it was merged as well.

Here is the commit containing the docs:


In short, in ansible.cfg under [defaults] set force_color = 1

--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/089760c2-dbdb-433d-8382-8a2b53cdc7de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
ma...@sivel.net
http://sivel.net/

Jason Harris

unread,
Sep 17, 2014, 4:28:27 AM9/17/14
to ansible...@googlegroups.com
Thanks. This was just what I was after!

Thanks,
   Jason


On Wednesday, September 17, 2014 12:01:47 AM UTC+2, Matt Martz wrote:
I actually just submitted a pull request to document the configuration to allow this earlier today.

It looks like it was merged as well.

Here is the commit containing the docs:


In short, in ansible.cfg under [defaults] set force_color = 1


On Tuesday, September 16, 2014, Jason Harris <jason.f...@gmail.com> wrote:
Hi All,

I am trying to capture ansible output with a python subprocess command. If I capture:

childProcess = subprocess.Popen("ansible-playbook ...", shell=True, subprocess.PIPE, subprocess.PIPE, cwd=dir)
res = childProcess.communicate()

Then res[0] will be the stdout of my ansible command, and res[1] will be the stderr of my ansible command, but both will be uncoloured...

Is there an easy way to force ansible to always issue colour output independent of the term type it is detecting?

Thanks,
   Jason

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages