Skip to content

Commit

Permalink
Add ability to turn off colored output (#32)
Browse files Browse the repository at this point in the history
* Add Action input to control colored Ansible output

* Update main.js

Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
  • Loading branch information
bswinnerton and dawidd6 authored Aug 1, 2021
1 parent 00e2fc8 commit 671974e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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, {
Expand Down

0 comments on commit 671974e

Please sign in to comment.