mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2025-09-05 08:25:46 -06:00
Add check mode option
This commit is contained in:
parent
245b181622
commit
95b662c1c8
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@ -97,6 +97,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
- name: With check mode
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
playbook: playbook.yml
|
||||||
|
directory: test
|
||||||
|
check: true
|
||||||
|
options: --inventory hosts
|
||||||
- name: With custom ansible.cfg
|
- name: With custom ansible.cfg
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
@ -37,6 +37,9 @@ inputs:
|
|||||||
no_color:
|
no_color:
|
||||||
description: Set to "true" if the Ansible output should not include colors (defaults to "false")
|
description: Set to "true" if the Ansible output should not include colors (defaults to "false")
|
||||||
required: false
|
required: false
|
||||||
|
check_mode:
|
||||||
|
description: Set to "true" to enable check (dry-run) mode
|
||||||
|
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
|
||||||
|
5
main.js
5
main.js
@ -17,6 +17,7 @@ async function main() {
|
|||||||
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")
|
const noColor = core.getInput("no_color")
|
||||||
|
const checkMode = core.getInput("check_mode")
|
||||||
const fileMode = 0600
|
const fileMode = 0600
|
||||||
|
|
||||||
let cmd = ["ansible-playbook", playbook]
|
let cmd = ["ansible-playbook", playbook]
|
||||||
@ -94,6 +95,10 @@ async function main() {
|
|||||||
process.env.ANSIBLE_FORCE_COLOR = "True"
|
process.env.ANSIBLE_FORCE_COLOR = "True"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (checkMode) {
|
||||||
|
cmd.push("--check")
|
||||||
|
}
|
||||||
|
|
||||||
let output = ""
|
let output = ""
|
||||||
await exec.exec(cmd.join(' '), null, {
|
await exec.exec(cmd.join(' '), null, {
|
||||||
listeners: {
|
listeners: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user