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

Via pip (Recommended)

# 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmdbsyncer_inventory-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmdbsyncer_inventory-0.2.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file cmdbsyncer_inventory-0.2.0.tar.gz.

File metadata

  • Download URL: cmdbsyncer_inventory-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for cmdbsyncer_inventory-0.2.0.tar.gz
Algorithm Hash digest
SHA256 987937185fe516ac3815e285a0a9412732b39dd7091861915036d70bfc3f0663
MD5 f50a4277ae0dc80de186f7535e4bc75a
BLAKE2b-256 335c9fb600b8603c186b2308d3559420e46e6138d95899d3dad30d0a703a5244

See more details on using hashes here.

File details

Details for the file cmdbsyncer_inventory-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cmdbsyncer_inventory-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e22fedb20511517eb0daa8d68e9ebf6a9554e604c216d8614c2e7466c260094b
MD5 42dc6e4ed20b10c0cd6c9d1056d341cc
BLAKE2b-256 345e9d4b63603c80a0a786d9efa729124cf4896c187b8f10789e43cba8f78cf4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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