Welcome to Nornir SQL inventory plugin!
If your device inventory is spread across SQL database tables and you would like to use it as Nornir inventory, you may consider looking on this project.
Installation
Install from pypi
pip install nornir-sql
Install from GitHUB
pip install git+https://github.com/realvitya/nornir_sql.git
Simple example
from nornir import InitNornir
host_query = """\
SELECT ciname AS name, ip AS hostname, region AS 'data.region'
FROM host_table
WHERE status='deployed'
"""
inventory = {
"plugin": "SQLInventory",
"options": {
"sql_connection": "sqlite:///inventory.db",
"hosts_query": hosts_query,
}
}
nr = InitNornir(inventory=inventory)
print(nr.inventory.hosts['FW1']['region'])
Configuration
This plugin is based on SQLAlchemy and supports all databases that SQLAlchemy does.
These configuration options can be used:
- sql_connection: SQLAlchemy connection stringFormat: {driver}://[user]:[password]@{DBSERVER}/{DATABASE}SQLite example:sqlite:///somedb.dbMSSQL example with domain user authentication:mssql+pymssql://ACME\\dbuser:verysecret@DBSRV1/INFRA
- hosts_query: Select statement which returns hosts inventory elements.The select must return at minimum the name field!Field names must match the expected Nornir inventory elements!The data elements are expected in data.[element] format. Quotation is needed!If groups are returned, the following groups_query also has to be specified!
- groups_query: Select statement which returns groups inventory elements.Same requirements apply as for the hosts_query.
- groups_file: path to a YAML file containing group definitions. Format is that same as used by SimpleInventoryThis parameter is ignored when groups_query or groups are specified!Using this parameter requires group assignments outside of this plugin! Check docs!
- groups: group definition as dict. Same restrictions and features apply as by using groups_file!Ignored when groups_query is specified!Using this parameter requires group assignments outside of this plugin! Check docs!
- defaults: This is a dictionary which contains inventory elements. These will be applied to hosts.
Metadata
Release files for nornir-sql 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nornir_sql-0.1.0.tar.gz | 5.9 kB | Without provenance | Details for nornir_sql-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nornir_sql-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nornir_sql-0.1.0-py3-none-any.whl |
Total release size: 12.5 kB
Release files / nornir_sql-0.1.0.tar.gz
| Download URL | nornir_sql-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ea59fd72dd0c97ef64d30eeb0c213bcef20316552661a2d17f5127ca3b6e6b4
|
|
BLAKE2b-256 checksum How to use checksums |
0c2f8b6bf1c597dd18bf8d737ec9b806acc78d68e9bde14b2d5d07513a72543e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / nornir_sql-0.1.0-py3-none-any.whl
| Download URL | nornir_sql-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5673594d7175d6c60c15fcbffe548550cf885bb488b450b3597361937abdbc29
|
|
BLAKE2b-256 checksum How to use checksums |
9444e8c49466b55297166e228ad963d4ca2f586c6328bc635b00d02d9cd6255b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for nornir-sql 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.