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) 
cmdbsyncer-install-plugin

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

Alternative: Manual installation

If the automatic installation doesn't work:

# 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
cmdbsyncer-install-plugin

Usage

After installation and running cmdbsyncer-install-plugin, 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 .

# 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.1.tar.gz (6.7 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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cmdbsyncer_inventory-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 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.1.tar.gz
Algorithm Hash digest
SHA256 b9ef0e483697b64e96058a5f4cb6ecb23bb037b05929d3fe818ee8175dcaac0b
MD5 a8aac695e32e2af2f9f1c6f32246f4bb
BLAKE2b-256 dd564fe4961433f9069a8e559837be6341365e1a06e57d7ed8380e7d4d42c98d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cmdbsyncer_inventory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a1702387c49d80aeb00f9dc25f62cecea005be319c862ca3ce624db44b5b4ed
MD5 c4a03e89a4784ad890b2455135723727
BLAKE2b-256 7632394d7e63ede97899c303cdad997613af99d97fdadd0d8caf07b38a445948

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