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-inventory --host monserveur --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]
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.1.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.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ansibase-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b6fb783d81e227bbb6b8ef4bd84abb1d73bb8b735d71ae6fbb85175b86720673
MD5 a5b7fcc19f776b16452052fe839a1e88
BLAKE2b-256 00aef0b03e2b4dbc0ffcd6fee4e7cf9a657db58bdf4545548d693afcb693f10d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ansibase-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6686718bcd9091c2d678a92e40777eb197f420a6eab79fd3b34dd95ac33ee11b
MD5 d535563dac76e96d67cf7b00a0210ae2
BLAKE2b-256 b019ae4451650ff73ac43c5f3337f161fc08e0ba92c12a971c698942707147b8

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