Skip to main content

Inventaire Ansible dynamique avec PostgreSQL

Project description

Ansibase

Inventaire Ansible dynamique avec PostgreSQL.

Installation

# -- Core uniquement
pip install ansibase

# -- Avec le plugin et script Ansible
pip install ansibase[ansible]

En utilisant le code source

# -- Core uniquement
pip install -e packages/ansibase

# -- Avec le plugin et script Ansible
pip install -e "packages/ansibase[ansible]"

Utilisation

En tant que bibliothèque Python

from ansibase import Database, DatabaseConfig, PgCrypto, InventoryBuilder

config = DatabaseConfig(host="localhost", port=5432, database="ansibase", user="ansibase", password="ansibase")
db = Database(config)
crypto = PgCrypto("ma_cle_de_chiffrement")

session = db.get_session()
builder = InventoryBuilder(session, crypto)
inventory = builder.build()

Script pour gerer la base de donnees

# Appliquer les migrations
ansibase-db upgrade --config ansibase.ini 

# Voir les migrations
ansibase-db history --config ansibase.ini

Script d'inventaire dynamique

# Lister l'inventaire complet
ansibase-inventory --list --config ansibase.ini

# Variables d'un hôte
ansibase-inventory --host monserveur --config ansibase.ini

Plugin Ansible

Ajouter dans ansible.cfg :

[defaults]
# ton repertoire des inventaires
inventory_plugins = ./inventory_plugins

[inventory]
enable_plugins = ansibase_ansible, auto

cree le lien symbolique du plugin dans votre repertoire des plugins

ln -s $(python -c "from pathlib import Path; import ansibase.ansible; print(Path(ansibase.ansible.__file__).parent)")/ansibase_ansible.py inventory_plugins/ansibase_ansible.py

Puis utiliser avec un fichier ansibase.yml :

plugin: ansibase_ansible
host: localhost
port: 5432
database: ansibase
user: ansibase
password: "mon_mot_de_passe"
encryption_key: "ma_cle"

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

ansibase-1.0.3.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

ansibase-1.0.3-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file ansibase-1.0.3.tar.gz.

File metadata

  • Download URL: ansibase-1.0.3.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ansibase-1.0.3.tar.gz
Algorithm Hash digest
SHA256 665d5b5d3ff2e1381331c11f4a0df808131a62c4cce012af3cfe8f1a2abfbbb8
MD5 d8f2b0a3575132e20634e62a6288974d
BLAKE2b-256 5ae08ce967c1add9eac44f20d77f929f2f618b6d3ede1b1e8189487a8f652d73

See more details on using hashes here.

File details

Details for the file ansibase-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: ansibase-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ansibase-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f80214822e8b815eec9e617b67d9bcaa3c9c62e49e0450bb2edaac9379e06383
MD5 e2d389583dbbb02bdbe4923e5261b151
BLAKE2b-256 535a69ab35af4409554291d3e606f6eca37774fab1e49ceb37fa18e998a1014c

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