Skip to content

Commit

Permalink
Add sudo option for root access (#16)
Browse files Browse the repository at this point in the history

Co-authored-by: ANDREA BIONDO s291512 <[email protected]>
Co-authored-by: Dawid Dziurla <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2021
1 parent f0b38f3 commit 03f941b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ inputs:
options:
description: Extra options that should be passed to ansible-playbook command
required: false
sudo:
description: Set to "true" if root is required for running your playbook
required: false
runs:
using: node12
main: main.js
Expand Down
6 changes: 5 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async function main() {
const vaultPassword = core.getInput("vault_password")
const knownHosts = core.getInput("known_hosts")
const options = core.getInput("options")
const sudo = core.getInput("sudo")

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

Expand Down Expand Up @@ -81,10 +82,13 @@ async function main() {
process.env.ANSIBLE_HOST_KEY_CHECKING = "False"
}

if (sudo) {
cmd.unshift("sudo")
}

process.env.ANSIBLE_FORCE_COLOR = "True"

await exec.exec(cmd.join(' '))

} catch (error) {
core.setFailed(error.message)
}
Expand Down

0 comments on commit 03f941b

Please sign in to comment.