action.playbook#
Docker-based GitHub Action that runs ansible-playbook. It is a Go program
(main.go) on top of go.ansible, packaged in an image
derived from arillso/ansible. All facts on this page come
from action.yml, main.go, Dockerfile and CHANGELOG.md in
https://github.com/arillso/action.playbook.
Facts#
Property |
Value |
|---|---|
Action name |
|
Latest release |
|
Runner |
|
Image base |
|
Image platforms |
|
Go library |
|
License |
MIT |
Usage#
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run playbook
id: ansible
uses: arillso/action.playbook@0.5.0
with:
playbook: site.yml
inventory: inventory.yml
private_key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
vault_password: ${{ secrets.VAULT_PASSWORD }}
- run: echo "status=${{ steps.ansible.outputs.status }} exit=${{ steps.ansible.outputs.exit_code }}"
Check mode for pull requests:
- uses: arillso/action.playbook@0.5.0
with:
playbook: site.yml
inventory: inventory.yml
dry_run: 'true' # --check --diff
output_file: ansible.log # keep stdout and stderr for a PR comment
Inputs#
Exactly as declared in action.yml on main. Inputs marked Unreleased
were added after 0.5.0 and are not available with @0.5.0.
Name |
Required |
Default |
Description |
|---|---|---|---|
|
no |
|
Timeout in minutes for the playbook execution (1-1440, default: 30). |
|
no |
|
Number of times to retry on failure (0-100, 0 = no retries, default: 0). |
|
no |
|
Delay in seconds between retries (0-3600, default: 30). |
|
no |
Name of the galaxy file in your workspace. |
|
|
no |
Forces the reinstallation of roles or collections from the Galaxy file. |
|
|
no |
Sets the API key used for authenticating to Ansible Galaxy. |
|
|
no |
Defines the URL of the Ansible Galaxy API server to interact with. |
|
|
no |
Sets the path to the directory where Galaxy collections are stored. |
|
|
no |
Disables GPG signature verification for Ansible Galaxy operations. |
|
|
no |
Forces the installation of collections with their dependencies from Galaxy. |
|
|
no |
Ignores SSL certificate validation for Ansible Galaxy requests. |
|
|
no |
Lists HTTP status codes to ignore during Galaxy signature validation. |
|
|
no |
Specifies the path to the GPG keyring used with Ansible Galaxy. |
|
|
no |
Enables offline mode, preventing any requests to Ansible Galaxy. |
|
|
no |
Allows the installation of pre-release versions from Ansible Galaxy. |
|
|
no |
Sets the required number of valid GPG signatures for Galaxy content. |
|
|
no |
Defines the path to the Ansible Galaxy requirements file. |
|
|
no |
Specifies a specific GPG signature to verify for Galaxy content. |
|
|
no |
Sets the timeout in seconds for Ansible Galaxy operations. |
|
|
no |
Enables automatic upgrading of Galaxy collections to the latest version. |
|
|
no |
Disables automatic resolution of dependencies in Ansible Galaxy. |
|
|
yes |
One or more inventory host files. Supports comma-separated (‘inv1.yml,inv2.yml’) or multiline YAML syntax. |
|
|
yes |
One or more playbooks to apply. Supports comma-separated (‘play1.yml,play2.yml’) or multiline YAML syntax. |
|
|
no |
Limits the playbook execution to a specific group of hosts. |
|
|
no |
Only run plays and tasks whose tags do not match these values. |
|
|
no |
Start the playbook at the task matching this name. |
|
|
no |
Executes only tasks and plays with specified tags. |
|
|
no |
Additional variables in key=value format. Supports comma-separated or multiline YAML syntax for multiple values. |
|
|
no |
Prepend directories to the module library path. Supports comma-separated or multiline YAML syntax for multiple paths. |
|
|
no |
|
Run ansible-lint on playbooks before execution. |
|
no |
Save Ansible stdout to a file (useful for capturing diff output for PR comments). |
|
|
no |
Executes a dry run, showing what changes would be made without making them. |
|
|
no |
Shows the differences in files and templates when changing them. |
|
|
no |
|
Enables both check and diff mode for a dry run without making changes. |
|
no |
Clears the fact cache for every host in the inventory. |
|
|
no |
Runs all handlers even if a task fails. |
|
|
no |
Outputs a list of matching hosts. |
|
|
no |
List all available tags. |
|
|
no |
List all tasks that would be executed. |
|
|
no |
Performs a syntax check on the playbook, without executing it. |
|
|
no |
Defines the number of parallel processes to use during playbook execution (1-1000, default: 5). |
|
|
no |
Specifies the identity to use when accessing an Ansible Vault. |
|
|
no |
Sets the password to use for decrypting an Ansible Vault. |
|
|
no |
Sets the verbosity level, ranging from 0 (minimal output) to 4 (maximum verbosity). |
|
|
no |
Specifies the SSH private key content for connections. The key is loaded into ssh-agent, making it available to ProxyCommand and bastion host connections. Should be stored in a GitHub Secret. |
|
|
no |
Passphrase for the SSH private key. If provided, the passphrase is used to unlock the key when adding it to ssh-agent. Should be stored in a GitHub Secret. |
|
|
no |
Additional SSH private keys to load into ssh-agent. Supports multiline YAML syntax for multiple keys. Requires private_key to be set. |
|
|
no |
Defines the username for making connections. |
|
|
no |
Sets the type of connection to use (e.g., SSH). |
|
|
no |
Overrides the default connection timeout in seconds. |
|
|
no |
Specifies common arguments to pass to all SSH-based connection methods (SSH, SCP, SFTP). |
|
|
no |
Provides extra arguments to pass only to SFTP. |
|
|
no |
Provides extra arguments to pass only to SCP. |
|
|
no |
Provides extra arguments to pass only to SSH. |
|
|
no |
SSH known hosts entries for host key verification. Supports multiline YAML syntax. |
|
|
no |
Enables privilege escalation, allowing operations to run as another user. |
|
|
no |
Specifies the method to use for privilege escalation (e.g., sudo). |
|
|
no |
Sets the user to impersonate when using privilege escalation. |
|
|
no |
Path to an ansible.cfg configuration file to use (sets ANSIBLE_CONFIG). Unreleased (not in 0.5.0). |
|
|
no |
Disables colorized output. Unreleased (not in 0.5.0). |
|
|
no |
Sets the stdout callback plugin for Ansible output (e.g. ‘yaml’, ‘json’, ‘minimal’). Unreleased (not in 0.5.0). |
|
|
no |
Comma-separated list of enabled callback plugins (e.g. ‘profile_tasks,timer’). Unreleased (not in 0.5.0). |
|
|
no |
Specifies the strategy plugin to use (e.g. ‘linear’, ‘free’, ‘mitogen_linear’). Unreleased (not in 0.5.0). |
|
|
no |
Limits the scope of gathered facts (e.g. ‘!all,!min,network’). Unreleased (not in 0.5.0). |
|
|
no |
Timeout in seconds for gathering facts (0-3600, 0 = ansible default). Unreleased (not in 0.5.0). |
|
|
no |
Path to local fact files loaded as host facts. Unreleased (not in 0.5.0). |
|
|
no |
Caching method to use for facts (e.g. ‘jsonfile’, ‘redis’, ‘memory’). Unreleased (not in 0.5.0). |
|
|
no |
Timeout in seconds for the fact cache (0 = no expiry). Unreleased (not in 0.5.0). |
|
|
no |
Interval in seconds for polling async tasks (0-3600, 0 = ansible default). Unreleased (not in 0.5.0). |
|
|
no |
Maximum percentage of hosts that can fail before the playbook aborts (0-100). Unreleased (not in 0.5.0). |
|
|
no |
Treats any task error as fatal, aborting the whole play. Unreleased (not in 0.5.0). |
|
|
no |
Method for file transfer over SSH (e.g. ‘scp’ or ‘sftp’). Unreleased (not in 0.5.0). |
|
|
no |
Path to a file containing the vault password (alternative to vault_password). Unreleased (not in 0.5.0). |
|
|
no |
Path to a file containing the SSH private key (alternative to private_key). Unreleased (not in 0.5.0). |
|
|
no |
Directory for Ansible temporary files. Unreleased (not in 0.5.0). |
Note
main.go reads galaxy_file and galaxy_force from the action input.
All other galaxy_* inputs are read only from environment variables named
ANSIBLE_GALAXY_<NAME> (for example ANSIBLE_GALAXY_API_KEY); a value
given under with: does not reach them. Set them under env: instead.
This applies to 0.5.0 and main.
Outputs#
Name |
Description |
|---|---|
|
|
|
Exit code of the failed Ansible command, taken from
|
The exit code values follow the ExitCode* constants of
go.ansible: 2 host failed, 3 unreachable, 4
parser error, 99 user abort, 250 unexpected error.
Behaviour#
Taken from run() in main.go:
Topic |
Behaviour |
|---|---|
Lists |
|
File checks |
Every |
Galaxy file |
Without |
SSH key |
|
Known hosts |
|
Vault |
|
Dry run |
|
Timeout and retries |
The whole run is cancelled after |
Lint |
|
Numeric inputs |
Out-of-range values abort the run, e.g. |
Environment |
Every input can also be set as |
Step summary |
Playbooks, status and duration are written to
|
Release Process#
Pushing a tag runs tag.yml: it checks that the image tag in action.yml
matches the release version, builds and pushes
ghcr.io/arillso/action.playbook for linux/amd64 and linux/arm64, and
creates the GitHub release.
See also
docker.ansible - base image of the action image
go.ansible - library that builds and runs the Ansible commands