Plugin Idea: postgresql_inventory

gebz97
Mon, 06 Oct 2025 18:30:22 +0000
Project Discussions

Hello Everyone, I’m Gebz (First post on the Ansible forums).

I’ve recently started working on a custom plugin for pulling dynamic inventory data from a postgresql table (since I didn’t find any that exist to my knowledge), and was looking for feedback regarding whether or not this feature would be useful to anyone else other than me.

You can checkout an initial version of how such a plugin would look like, but keep in mind the design choice is opinionated (and could be wrong, which is why I would value your feedback)

github.com/gebz97/ansible-custom

plugins/inventory/postgresql_inventory.py

master

# -*- coding: utf-8 -*-

# Copyright: (c) 2025, Aly Ghobashy (@gebz97) <gebz97@proton.me>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type

DOCUMENTATION = r"""
name: postgresql_inventory
short_description: PostgreSQL backed dynamic inventory
author: Aly Ghobashy (@gebz97)
description:
    - Fetch inventory hosts from a PostgreSQL database.
options:
    plugin:
        description: Token that ensures this is a source file for the plugin.
        required: true
        type: str

This file has been truncated. show original

Would love to hear your thoughts

5 posts - 3 participants