From 260954ef6acba4083154a41854204fbae710f88a Mon Sep 17 00:00:00 2001 From: Brooks Swinnerton Date: Sun, 1 Aug 2021 10:38:43 -0400 Subject: [PATCH] Add Action input to control colored Ansible output --- action.yml | 3 +++ main.js | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c35442d..0309b40 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 runs: using: node12 main: main.js diff --git a/main.js b/main.js index 81e200b..f94868e 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 no_color = 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 (no_color) { + process.env.ANSIBLE_NOCOLOR = "True" + } else { + process.env.ANSIBLE_FORCE_COLOR = "True" + } await exec.exec(cmd.join(' ')) } catch (error) {