1
0
Fork 0
mirror of https://github.com/dawidd6/action-ansible-playbook.git synced 2024-11-22 15:32:18 +00:00

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>
This commit is contained in:
Brooks Swinnerton 2021-08-01 11:03:21 -04:00 committed by GitHub
parent 00e2fc8809
commit 671974ed60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -31,6 +31,9 @@ inputs:
sudo: sudo:
description: Set to "true" if root is required for running your playbook description: Set to "true" if root is required for running your playbook
required: false required: false
no_color:
description: Set to "true" if the Ansible output should not include colors (defaults to "false")
required: false
outputs: outputs:
output: output:
description: The captured output of both stdout and stderr from the Ansible Playbook run description: The captured output of both stdout and stderr from the Ansible Playbook run

View file

@ -15,6 +15,7 @@ async function main() {
const knownHosts = core.getInput("known_hosts") const knownHosts = core.getInput("known_hosts")
const options = core.getInput("options") const options = core.getInput("options")
const sudo = core.getInput("sudo") const sudo = core.getInput("sudo")
const noColor = core.getInput("no_color")
let cmd = ["ansible-playbook", playbook] let cmd = ["ansible-playbook", playbook]
@ -79,7 +80,11 @@ async function main() {
cmd.unshift("sudo", "-E", "env", `PATH=${process.env.PATH}`) cmd.unshift("sudo", "-E", "env", `PATH=${process.env.PATH}`)
} }
if (noColor) {
process.env.ANSIBLE_NOCOLOR = "True"
} else {
process.env.ANSIBLE_FORCE_COLOR = "True" process.env.ANSIBLE_FORCE_COLOR = "True"
}
let output = "" let output = ""
await exec.exec(cmd.join(' '), null, { await exec.exec(cmd.join(' '), null, {