mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2025-04-18 13:53:34 +00:00
Compare commits
17 commits
Author | SHA1 | Date | |
---|---|---|---|
|
5966a43d57 | ||
|
23bc8e29ed | ||
|
a4133a9690 | ||
|
a4d1256d3c | ||
|
245b181622 | ||
|
fda8a7386a | ||
|
27828f1042 | ||
|
241ff10e9a | ||
|
85f47e79c9 | ||
|
61ed42d89c | ||
|
d6db4b2224 | ||
|
671eb8d192 | ||
|
8127eb81bd | ||
|
ec769f0156 | ||
|
a8c07a7430 | ||
|
b22f54b51e | ||
|
c97d71562f |
6 changed files with 43 additions and 28 deletions
9
.github/workflows/test.yml
vendored
9
.github/workflows/test.yml
vendored
|
@ -64,7 +64,7 @@ jobs:
|
||||||
PermitRootLogin no
|
PermitRootLogin no
|
||||||
Subsystem sftp /usr/lib/openssh/sftp-server
|
Subsystem sftp /usr/lib/openssh/sftp-server
|
||||||
EOF
|
EOF
|
||||||
sudo systemctl restart sshd
|
sudo systemctl restart ssh
|
||||||
echo 'SSH_KNOWN_HOSTS<<EOF' >> $GITHUB_ENV
|
echo 'SSH_KNOWN_HOSTS<<EOF' >> $GITHUB_ENV
|
||||||
echo $(ssh-keyscan localhost) >> $GITHUB_ENV
|
echo $(ssh-keyscan localhost) >> $GITHUB_ENV
|
||||||
echo 'EOF' >> $GITHUB_ENV
|
echo 'EOF' >> $GITHUB_ENV
|
||||||
|
@ -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_mode: true
|
||||||
|
options: --inventory hosts
|
||||||
- name: With custom ansible.cfg
|
- name: With custom ansible.cfg
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -8,7 +8,7 @@ Should work on any OS, if `ansible-playbook` command is available in `PATH`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Run playbook
|
- name: Run playbook
|
||||||
uses: dawidd6/action-ansible-playbook@v2
|
uses: dawidd6/action-ansible-playbook@v3
|
||||||
with:
|
with:
|
||||||
# Required, playbook filepath
|
# Required, playbook filepath
|
||||||
playbook: deploy.yml
|
playbook: deploy.yml
|
||||||
|
|
|
@ -34,13 +34,19 @@ inputs:
|
||||||
sudo:
|
sudo:
|
||||||
description: Set to "true" if root is required for running your playbook
|
description: Set to "true" if root is required for running your playbook
|
||||||
required: false
|
required: false
|
||||||
|
default: false
|
||||||
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
|
||||||
|
default: false
|
||||||
|
check_mode:
|
||||||
|
description: Set to "true" to enable check (dry-run) mode
|
||||||
|
required: false
|
||||||
|
default: 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
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node20
|
||||||
main: main.js
|
main: main.js
|
||||||
post: post.js
|
post: post.js
|
||||||
|
|
9
main.js
9
main.js
|
@ -15,8 +15,9 @@ 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")
|
const sudo = core.getBooleanInput("sudo")
|
||||||
const noColor = core.getInput("no_color")
|
const noColor = core.getBooleanInput("no_color")
|
||||||
|
const checkMode = core.getBooleanInput("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: {
|
||||||
|
|
39
package-lock.json
generated
39
package-lock.json
generated
|
@ -6,18 +6,18 @@
|
||||||
"": {
|
"": {
|
||||||
"name": "action-ansible-playbook",
|
"name": "action-ansible-playbook",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"yaml": "^2.3.4"
|
"yaml": "^2.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.10.1",
|
"version": "1.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz",
|
||||||
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
|
"integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^2.0.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"uuid": "^8.3.2"
|
"@actions/http-client": "^2.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/exec": {
|
"node_modules/@actions/exec": {
|
||||||
|
@ -59,9 +59,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.28.2",
|
"version": "5.28.5",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
||||||
"integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==",
|
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
@ -69,18 +70,14 @@
|
||||||
"node": ">=14.0"
|
"node": ">=14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/uuid": {
|
|
||||||
"version": "8.3.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
|
||||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
|
||||||
"bin": {
|
|
||||||
"uuid": "dist/bin/uuid"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/yaml": {
|
"node_modules/yaml": {
|
||||||
"version": "2.3.4",
|
"version": "2.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.1.tgz",
|
||||||
"integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==",
|
"integrity": "sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ==",
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"yaml": "bin.mjs"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14"
|
"node": ">= 14"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
"name": "action-ansible-playbook",
|
"name": "action-ansible-playbook",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"yaml": "^2.3.4"
|
"yaml": "^2.7.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue