Issue
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 ?
Solution
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#ansible-force-color
You can either set the environment variable ANSIBLE_FORCE_COLOR
to True
, or set the config defaults.force_color
to True
in your ansible config file (local ansible.cfg
, ~/.ansible.cfg
or /etc/ansible/ansible.cfg
)
Answered By - zigarn