Skip to main content

CMDBSyncer Inventory Plugin

PyPI version Python Support License: MIT

An Ansible dynamic inventory plugin that fetches host and group information from CMDBSyncer.

Installation

# Install the package
pip install cmdbsyncer-inventory

# Auto-install plugin for Ansible (run once after installation)
python -m cmdbsyncer_inventory

That's it! The plugin is now automatically available to Ansible.

Alternative methodm

Method 1: Using the install command (if available)

cmdbsyncer-install-plugin  # If console scripts work on your system

Method 2: Manual copy to project

# Install the package
pip install cmdbsyncer-inventory

# Manually copy to your project
mkdir -p inventory_plugins
python -c "
import cmdbsyncer_inventory
from pathlib import Path
import shutil

src = Path(cmdbsyncer_inventory.__file__).parent / 'inventory_plugins' / 'cmdbsyncer_inventory.py'
shutil.copy2(src, 'inventory_plugins/cmdbsyncer_inventory.py')
print('Plugin copied to ./inventory_plugins/')
"

Via pip from source

pip install git+https://github.com/kuhn-ruess/cmdbsyncer-inventory.git
python -m cmdbsyncer_inventory

Usage

After installation and running python -m cmdbsyncer_inventory, the plugin is available to Ansible in two transport modes:

  • local (default): shells out to the local cmdbsyncer CLI. Use this when the Ansible control node and the Syncer run on the same host — no auth, no HTTP, fastest.
  • http: GETs /api/v1/inventory/ansible/<provider> from a remote Syncer over HTTPS. Use this from a separate Ansible control node.

Local mode

# inventory.yml
plugin: cmdbsyncer_inventory
mode: local         # default — can be omitted
provider: ansible   # default — names a provider registered in the Syncer
# cmdbsyncer_bin: /opt/cmdbsyncer/cmdbsyncer    # optional override
ansible-inventory -i inventory.yml --list
ansible-playbook -i inventory.yml your-playbook.yml

The Syncer's UI runner sets CMDBSYNCER_INVENTORY_PROVIDER per-playbook based on its manifest, so the same inventory YAML works for every dispatched playbook.

HTTP mode

# inventory.yml
plugin: cmdbsyncer_inventory
mode: http
provider: ansible
api_url: https://your-cmdbsyncer-instance.com
# username / password optional — prefer env vars
export CMDBSYNCER_APIUSER="your_username"
export CMDBSYNCER_APIPASSWORD="your_password"

ansible-inventory -i inventory.yml --list

Configuration Options

Option Required Type Default Description
plugin Yes string — Must be cmdbsyncer_inventory
mode No string local local or http — see above
provider No string ansible Name of a provider registered in the Syncer's inventory registry (e.g. ansible, cmk_sites)
cmdbsyncer_bin No string cmdbsyncer Path to the cmdbsyncer CLI (local mode only)
api_url http only string — Syncer base URL (http mode only)
username No string — API username (http mode; falls back to CMDBSYNCER_APIUSER)
password No string — API password (http mode; falls back to CMDBSYNCER_APIPASSWORD)
verify_ssl No bool true Verify TLS certificates (http mode only)

Both mode and provider may also be set via env vars (CMDBSYNCER_INVENTORY_MODE, CMDBSYNCER_INVENTORY_PROVIDER); env wins over the YAML so the same inventory file works for many playbooks.

Example Output

The plugin will create Ansible inventory with hosts and groups based on your CMDBSyncer configuration. Example structure:

{
  "_meta": {
    "hostvars": {
      "server1.example.com": {
        "ansible_host": "10.0.0.1",
        "ansible_user": "admin",
        "environment": "production"
      }
    }
  },
  "production": {
    "hosts": ["server1.example.com"]
  },
  "web": {
    "hosts": ["server1.example.com"]  
  }
}

Requirements

  • Python 3.7+
  • Ansible Core 2.12+
  • CMDBSyncer instance with API access

Development

Local Development Setup

# Clone the repository
git clone https://github.com/kuhn-ruess/cmdbsyncer-inventory.git
cd cmdbsyncer-inventory

# Install in development mode
pip install -e .

# Install plugin for Ansible
python -m cmdbsyncer_inventory

# Test the plugin
ansible-inventory -i example-inventory.yml --list

Building for PyPI

# Install build tools
pip install build twine

# Build package
python -m build

# Upload to PyPI
python -m twine upload dist/*

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Metadata

Release files for cmdbsyncer-inventory 0.2.0

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

Source distribution (sdist)

Source distribution for cmdbsyncer-inventory 0.2.0
File Size Uploaded Provenance
cmdbsyncer_inventory-0.2.0.tar.gz 9.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cmdbsyncer-inventory 0.2.0
File Interpreter ABI Platform
cmdbsyncer_inventory-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / cmdbsyncer_inventory-0.2.0.tar.gz

Download URL cmdbsyncer_inventory-0.2.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
987937185fe516ac3815e285a0a9412732b39dd7091861915036d70bfc3f0663
BLAKE2b-256 checksum
How to use checksums
335c9fb600b8603c186b2308d3559420e46e6138d95899d3dad30d0a703a5244
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / cmdbsyncer_inventory-0.2.0-py3-none-any.whl

Download URL cmdbsyncer_inventory-0.2.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e22fedb20511517eb0daa8d68e9ebf6a9554e604c216d8614c2e7466c260094b
BLAKE2b-256 checksum
How to use checksums
345e9d4b63603c80a0a786d9efa729124cf4896c187b8f10789e43cba8f78cf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for cmdbsyncer-inventory 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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