From 671974ed60e946e11964cb0c26e69caaa4b1f559 Mon Sep 17 00:00:00 2001 From: Brooks Swinnerton Date: Sun, 1 Aug 2021 11:03:21 -0400 Subject: [PATCH] Add ability to turn off colored output (#32) * Add Action input to control colored Ansible output * Update main.js Co-authored-by: Dawid Dziurla --- action.yml | 3 +++ main.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d30ddbf..495185e 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,9 @@ inputs: sudo: description: Set to "true" if root is required for running your playbook required: false + no_color: + description: Set to "true" if the Ansible output should not include colors (defaults to "false") + required: false outputs: output: description: The captured output of both stdout and stderr from the Ansible Playbook run diff --git a/main.js b/main.js index 055fc18..147f323 100644 --- a/main.js +++ b/main.js @@ -15,6 +15,7 @@ async function main() { const knownHosts = core.getInput("known_hosts") const options = core.getInput("options") const sudo = core.getInput("sudo") + const noColor = core.getInput("no_color") let cmd = ["ansible-playbook", playbook] @@ -79,7 +80,11 @@ async function main() { cmd.unshift("sudo", "-E", "env", `PATH=${process.env.PATH}`) } - process.env.ANSIBLE_FORCE_COLOR = "True" + if (noColor) { + process.env.ANSIBLE_NOCOLOR = "True" + } else { + process.env.ANSIBLE_FORCE_COLOR = "True" + } let output = "" await exec.exec(cmd.join(' '), null, {