Skip to main content

Ansible Inventory Plugin for CMDBSyncer

Project description

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 automatically available to Ansible. You just need to:

  1. Create an inventory configuration file (e.g., inventory.yml):
plugin: cmdbsyncer_inventory
api_url: https://your-cmdbsyncer-instance.com
username: your_username  # Optional if using environment variables
password: your_password  # Optional if using environment variables
  1. Set environment variables (recommended for credentials):
export CMDBSYNCER_APIUSER="your_username"
export CMDBSYNCER_APIPASSWORD="your_password"
  1. Use with ansible commands:
# Test the inventory
ansible-inventory -i inventory.yml --list

# Run playbooks
ansible-playbook -i inventory.yml your-playbook.yml

Note: No ansible.cfg configuration needed after automatic installation!

Configuration Options

Option Required Type Description
plugin Yes string Must be cmdbsyncer_inventory
api_url Yes string URL to your CMDBSyncer instance
username No string API username (can use CMDBSYNCER_APIUSER env var)
password No string API password (can use CMDBSYNCER_APIPASSWORD env var)

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

Project details


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.1.4.tar.gz (7.3 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.1.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cmdbsyncer_inventory-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e334f6f1a97a434899bdf17a0a942d9b28c1d02e8a6e5c6db405e43582db87b9
MD5 bfc6ab848d982947ffff195eba507050
BLAKE2b-256 674d8ac99adb1e91771ad8452c058d876027cf3476c1c7ca2b9742eb9e89a015

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cmdbsyncer_inventory-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 19be7d6bf3d5dd0338b12dd418a43a52bf9283b80e1f490834c32241ce6613dd
MD5 169a3c955e19c5ddc9de3cbcedbd20e6
BLAKE2b-256 6ff81fd91f385cc058e2e07e8c61af6fd7fb696e0291d642168de4e1428926bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page