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
# 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 colorised output that would have been displayed had the Ansible playbook been run from the command line directly is not visible.
Is there a way we can enable the colorised output to be visible when executed from the shell script?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With