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

Install Playbook Mate as an isolated command-line application with pipx:

pipx install playbook-mate
pbm --version

Alternatively, install it into the active Python environment:

python3 -m pip install playbook-mate

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.2

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.2
File Size Uploaded
playbook_mate-2.0.2.tar.gz 15.2 kB Details

Built distribution (wheel)

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

Total release size: 27.5 kB

Release files / playbook_mate-2.0.2.tar.gz

Download URL playbook_mate-2.0.2.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fa1507cbb0b01a2361e592ef9a38b260b431dda2f4e17ec1fc8b24dceb95b181
BLAKE2b-256 checksum
How to use checksums
53f6a58a880e48a1397d8f107abbb79e88b845e018e6b2c78962e0542aa8e0b5
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.2-py3-none-any.whl

Download URL playbook_mate-2.0.2-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cf28c2d3c5dcdf1596154dc5e90bc6ab23832658cecddaa265c1beb64813fd5
BLAKE2b-256 checksum
How to use checksums
036e21447dc92d1d5597dc2c8beba3f77d088857793d7932d72efb279cc58cda
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

This release

2.0.2 This release

2 release files

2.0.1

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