mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2024-12-27 10:36:09 -07:00
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>
This commit is contained in:
parent
f0b38f33e9
commit
03f941b221
|
@ -28,6 +28,9 @@ inputs:
|
||||||
options:
|
options:
|
||||||
description: Extra options that should be passed to ansible-playbook command
|
description: Extra options that should be passed to ansible-playbook command
|
||||||
required: false
|
required: false
|
||||||
|
sudo:
|
||||||
|
description: Set to "true" if root is required for running your playbook
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: node12
|
using: node12
|
||||||
main: main.js
|
main: main.js
|
||||||
|
|
6
main.js
6
main.js
|
@ -14,6 +14,7 @@ async function main() {
|
||||||
const vaultPassword = core.getInput("vault_password")
|
const vaultPassword = core.getInput("vault_password")
|
||||||
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")
|
||||||
|
|
||||||
let cmd = ["ansible-playbook", playbook]
|
let cmd = ["ansible-playbook", playbook]
|
||||||
|
|
||||||
|
@ -81,10 +82,13 @@ async function main() {
|
||||||
process.env.ANSIBLE_HOST_KEY_CHECKING = "False"
|
process.env.ANSIBLE_HOST_KEY_CHECKING = "False"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sudo) {
|
||||||
|
cmd.unshift("sudo")
|
||||||
|
}
|
||||||
|
|
||||||
process.env.ANSIBLE_FORCE_COLOR = "True"
|
process.env.ANSIBLE_FORCE_COLOR = "True"
|
||||||
|
|
||||||
await exec.exec(cmd.join(' '))
|
await exec.exec(cmd.join(' '))
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user