Skip to content

Commit 03f941b

Browse files
obbiondoANDREA BIONDO s291512dawidd6
authored
Add sudo option for root access (#16)
Co-authored-by: ANDREA BIONDO s291512 <s291512@studenti.polito.it> Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
1 parent f0b38f3 commit 03f941b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ inputs:
2828
options:
2929
description: Extra options that should be passed to ansible-playbook command
3030
required: false
31+
sudo:
32+
description: Set to "true" if root is required for running your playbook
33+
required: false
3134
runs:
3235
using: node12
3336
main: main.js

main.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async function main() {
1414
const vaultPassword = core.getInput("vault_password")
1515
const knownHosts = core.getInput("known_hosts")
1616
const options = core.getInput("options")
17+
const sudo = core.getInput("sudo")
1718

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

@@ -81,10 +82,13 @@ async function main() {
8182
process.env.ANSIBLE_HOST_KEY_CHECKING = "False"
8283
}
8384

85+
if (sudo) {
86+
cmd.unshift("sudo")
87+
}
88+
8489
process.env.ANSIBLE_FORCE_COLOR = "True"
8590

8691
await exec.exec(cmd.join(' '))
87-
8892
} catch (error) {
8993
core.setFailed(error.message)
9094
}

0 commit comments

Comments
 (0)