Skip to main content

Playbook Mate

pbm is a concise CLI for inspecting inventories, validating Ansible® projects, and running playbooks. Think of it as a small companion for the repetitive parts of working with an Ansible project

pbm does not replace Ansible. It helps you inspect an inventory, validate project structure, understand playbook variables, and run playbooks with predictable commands

Contents

Get started

Requirements

Python 3.11 or newer is required. ansible-core and PyYAML are installed automatically. A supported project must contain ansible.cfg and a playbooks/ directory

Install

python3 -m pip install \
  "git+https://github.com/neuron22/playbook-mate.git@v2.0.1"
pbm --version

Run the first checks

Open an Ansible project and let pbm discover its configuration:

cd /path/to/your/ansible-project
pbm check
pbm inventory
pbm playbooks

pbm check validates the project without connecting to managed hosts

To try Playbook Mate with the bundled example:

git clone --branch v2.0.1 --depth 1 \
  https://github.com/neuron22/playbook-mate.git
cd playbook-mate/examples/basic
pbm check
pbm inventory
pbm info hello

The complete example is available in examples/basic

Commands

pbm --help
pbm --version
pbm COMMAND --help

Inventory

pbm inventory
pbm inventory --list
pbm inventory --list --yaml
pbm inventory --host HOST
Option Description
--list Show the complete inventory with variables
--host HOST Show variables for a host
-y, --yaml Output YAML instead of JSON

With no options, the command displays the inventory graph. Pass additional ansible-inventory arguments after --:

pbm inventory -- --vars

Playbooks

pbm playbooks

Lists playbooks available in the project's playbooks/ directory.

Validation

pbm check
pbm check PLAYBOOK
pbm check --skip-inventory
Argument or option Description
PLAYBOOK Validate only the specified playbook
--skip-inventory Skip inventory validation

The command validates the inventory, argument_specs.yml, consistency between role defaults and argument specs, and playbook syntax. It does not connect to managed hosts.

Playbook information

pbm info PLAYBOOK

Displays the playbook's roles and their variable contracts, including required values, types, descriptions, choices, and defaults.

Run a playbook

pbm run PLAYBOOK -l TARGET [OPTIONS]
Option Description
-l, --limit, --target TARGET Target host, group, or Ansible pattern; required
-e, --extra-vars VARS key=value, YAML/JSON, or @vars.yml; may be repeated
-C, --check Run in check mode without applying changes
-D, --diff Show file and template changes
-v, --verbose Increase verbosity; may be repeated as -vv or -vvv
-t, --tags TAGS Run only tasks with the specified tags; may be repeated
--skip-tags TAGS Skip tasks with the specified tags; may be repeated

Examples:

pbm run ping -l app_servers
pbm run deploy_app -l app01 -e app_version=2.0 -e environment=stage
pbm run deploy_app -l app_servers -e @deploy-vars.yml --check --diff

Pass additional ansible-playbook arguments after --:

pbm run ping -l app_servers -- --list-hosts
pbm run deploy_app -l app01 -e app_version=2.0 -- -K

Inventory example

A complete minimal project is available in examples/basic. A YAML inventory can be structured as follows:

---
all:
  hosts:
    standalone01:
      ansible_host: 192.0.2.10
      ansible_user: deploy

  children:
    app_servers:
      vars:
        ansible_user: deploy
      hosts:
        app01:
          ansible_host: 192.0.2.11
        app02:
          ansible_host: 192.0.2.12

Argument specs example

# roles/app/meta/argument_specs.yml
---
argument_specs:
  main:
    short_description: Install an application
    options:
      app_name:
        type: str
        required: true
        description: Short application name
      app_user:
        type: str
        default: app
        description: System user for the application
      retries:
        type: int
        default: 3
        choices: [1, 3, 5]
        description: Number of retry attempts

Actual default values must also be defined in roles/app/defaults/main.yml:

---
app_user: app
retries: 3

Defaults in both files must match; pbm check validates this rule. Options with required: true must not define a default.

Development

Clone the repository and install it in editable mode with the development dependencies:

git clone https://github.com/neuron22/playbook-mate.git
cd playbook-mate
python3 -m pip install -e '.[dev]'

Run the same checks used by CI:

ruff check playbook_mate tests
ruff format --check playbook_mate tests
python3 -m unittest discover -s tests -v

License

Playbook Mate is available under the MIT License.

Trademark

Ansible is a registered trademark of Red Hat, LLC in the United States and other countries. Playbook Mate is an independent project and is not affiliated with or endorsed by Red Hat

Metadata

Release files for playbook-mate 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for playbook-mate 2.0.1
File Size Uploaded
playbook_mate-2.0.1.tar.gz 15.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for playbook-mate 2.0.1
File Interpreter ABI Platform
playbook_mate-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / playbook_mate-2.0.1.tar.gz

Download URL playbook_mate-2.0.1.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3f063dac50dbf64dd8e9db9acb85e1b5649c2bbaded3bf55b285b412988f11b6
BLAKE2b-256 checksum
How to use checksums
81f6b5dff39af9658f9abb5a9a4f4b0ea72c355101b7c527d55330c525d7bd55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release files / playbook_mate-2.0.1-py3-none-any.whl

Download URL playbook_mate-2.0.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ccbbdfba32d7c41c17577fdec3e5931643095e9fdea17353d0f01c2b4a584c9
BLAKE2b-256 checksum
How to use checksums
efc381b14e5d9f6bacac71d7fb9ea6aeb8f304cf61e8986d3bb67ca016f2dbb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.2

2 release files

This release

2.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page