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)

pip install cmdbsyncer-inventory

Via pip from source

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

Usage

After installation, 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. Configure ansible.cfg (optional, for broader plugin availability):
[defaults]
# Optional: specify additional paths if needed

[inventory]
# Enable the plugin (ansible-core 2.12+ auto-enables installed plugins)
enable_plugins = host_list, script, auto, yaml, ini, toml, cmdbsyncer_inventory
  1. Use with ansible commands:
# Test the inventory
ansible-inventory -i inventory.yml --list

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

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 (requires credentials)
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.0.tar.gz (5.8 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.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cmdbsyncer_inventory-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 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.0.tar.gz
Algorithm Hash digest
SHA256 bf76d1b2ea67ca891ed4be4998f978867ea0ab91217dbdda25e1312d18a8d63d
MD5 0b22558a134875234294f7ab2f315dda
BLAKE2b-256 0923a86871717b5e17b9624d147129a734718673d9d9b8a54d32f54f85ba31ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cmdbsyncer_inventory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 088d28e9a623e2a3855626e9264ba2cbeae930776f51daf4815337a88d80ece5
MD5 3aa23b69b71c3f820595afc417291307
BLAKE2b-256 ba51ac44cc8d4744df4783256afe778618bfde00be1b2710bef08b600f9519d4

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