How can we print colored output of ansible task when ansible is run through a shell script?

Viewed 2727

I have an ansible playbook that is called from a bash script as show in the below snippet ?

#!/bin/bash
# Name of script: execute_ansible

# Some pre-processing
.....
# 

# Execute ansible playbook
ansible-playbook my_ansible_playbook

This script is executed as below:

$ bash execute_ansible

When executed with the above command, the ansible playbook my_ansible_playbook is executed correctly. However, the colorized output that would have been displayed had the the ansible playbook been run from the command line directly is not visible. Is there a way we can enable the colorized output to be visible when executed from the shell script ?

1 Answers
Related