Skip to content

Commit 671974e

Browse files
bswinnertondawidd6
andauthored
Add ability to turn off colored output (#32)
* Add Action input to control colored Ansible output * Update main.js Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
1 parent 00e2fc8 commit 671974e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ inputs:
3131
sudo:
3232
description: Set to "true" if root is required for running your playbook
3333
required: false
34+
no_color:
35+
description: Set to "true" if the Ansible output should not include colors (defaults to "false")
36+
required: false
3437
outputs:
3538
output:
3639
description: The captured output of both stdout and stderr from the Ansible Playbook run

main.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async function main() {
1515
const knownHosts = core.getInput("known_hosts")
1616
const options = core.getInput("options")
1717
const sudo = core.getInput("sudo")
18+
const noColor = core.getInput("no_color")
1819

1920
let cmd = ["ansible-playbook", playbook]
2021

@@ -79,7 +80,11 @@ async function main() {
7980
cmd.unshift("sudo", "-E", "env", `PATH=${process.env.PATH}`)
8081
}
8182

82-
process.env.ANSIBLE_FORCE_COLOR = "True"
83+
if (noColor) {
84+
process.env.ANSIBLE_NOCOLOR = "True"
85+
} else {
86+
process.env.ANSIBLE_FORCE_COLOR = "True"
87+
}
8388

8489
let output = ""
8590
await exec.exec(cmd.join(' '), null, {

0 commit comments

Comments
 (0)