1
0
Fork 0
mirror of https://github.com/dawidd6/action-ansible-playbook.git synced 2025-04-12 02:47:06 +00:00

Add check mode option

This commit is contained in:
Alex van den Hoogen 2025-02-10 10:06:28 +01:00
parent 245b181622
commit 95b662c1c8
3 changed files with 15 additions and 0 deletions
.github/workflows
action.ymlmain.js

View file

@ -97,6 +97,13 @@ jobs:
steps:
- name: Checkout code
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
uses: ./
with:

View file

@ -37,6 +37,9 @@ inputs:
no_color:
description: Set to "true" if the Ansible output should not include colors (defaults to "false")
required: false
check_mode:
description: Set to "true" to enable check (dry-run) mode
required: false
outputs:
output:
description: The captured output of both stdout and stderr from the Ansible Playbook run

View file

@ -17,6 +17,7 @@ async function main() {
const options = core.getInput("options")
const sudo = core.getInput("sudo")
const noColor = core.getInput("no_color")
const checkMode = core.getInput("check_mode")
const fileMode = 0600
let cmd = ["ansible-playbook", playbook]
@ -94,6 +95,10 @@ async function main() {
process.env.ANSIBLE_FORCE_COLOR = "True"
}
if (checkMode) {
cmd.push("--check")
}
let output = ""
await exec.exec(cmd.join(' '), null, {
listeners: {