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 --config ansibase.ini upgrade 

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

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]
inventory_plugins = <chemin_vers_site-packages>/ansibase/ansible

[inventory]
enable_plugins = ansibase-ansible, auto

<chemin_vers_site-packages> peut etre obtenu en utilisant la commande

python -c "from pathlib import Path; import ansibase.ansible; print(Path(ansibase.ansible.__file__).parent.parent.parent)"

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.2.tar.gz (16.2 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.2-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ansibase-1.0.2.tar.gz
  • Upload date:
  • Size: 16.2 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.2.tar.gz
Algorithm Hash digest
SHA256 6f38ed8cb0afd08028e59652f287f0b760b1a7ea8940b632ba68d464b962cff6
MD5 67b5fcf8ccb459818d5e3a0536cf464d
BLAKE2b-256 9f3346e7213575f507bb9827c61c0c64c22dde907139583c629621061c426718

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ansibase-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 635e6eceb0daa838c5f16431d7d380085d940b77f733a02b003589653474a7af
MD5 20f9c5b83c63f121a6a0f2ea9d8d22ac
BLAKE2b-256 3d981391d688fb4bd0210c613f6297dd21a075370a88df21cb63a9b6c499aa6a

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