-
Notifications
You must be signed in to change notification settings - Fork 0
Autoconfig create inventory.yml using Python Script
Hamzaukw edited this page Sep 9, 2025
·
1 revision
This script automates the setup and processing of system configurations in an Ansible-based environment. Command to run: bnsc.exec This command is defined inside of luxnix/devenv/scripts as a executable script. direnv allow is prerequisite to run bnsc.exec short command.
-
Host Facts
Ensure host facts are available at ansible/cmdb. If they are not available, generate them by running the script located at scripts/ansible-cmdb.sh using command run scripts/ansible-cmdb.sh. -
Ansible Inventory
Verify that the inventory file is present at ansible/inventory.
1. main Function (scripts/autoconf-pipeline.py)
- Acts as the entry point for the script when run directly.
-
Sets up paths:
-
ansible_root(/ansible): Path to Ansible resources (inventory and cmdb). -
autoconf_out(/autoconf): Output directory for the ETL pipeline. -
nix_out: Target directory for configuration files.
-
- Call the
pipefunction with the above paths to start the process.
2. Top-Level pipe Function (lx_administration/autoconf/main.py)
-
Coordinates the ETL pipeline by calling two sub-pipelines:
-
etl_pipe:- Extracts inventory and host facts from Ansible resources.
- Generates a merged inventory file (
inventory.yml) inautoconf_out.
-
nix_pipe:- Processes Nix templates using data from
autoconf_out. - Generates Nix configuration files in
nix_out.
- Processes Nix templates using data from
-
-
Parameters:
-
ansible_root: Directory containing Ansible inventory and facts. -
autoconf_out: Directory where intermediate results are stored. -
nix_out: Output directory for Nix configurations. -
conf_parent: Directory containing Nix templates.
-
- Logger: Logs the process for debugging and monitoring.
3. pipe Function in (lx_administration/autoconf/imports/main.py)
-
Runs
ansible_etlto perform the ETL process. - Logs input paths and the subnet being processed.
- Ensures the output directory (
autoconf_out) exists.
4. ansible_etl Function (lx_administration/autoconf/imports/main.py)
- Loads the Ansible inventory from
hosts.ini. - Loads host facts from the
cmdbdirectory. - Merges host facts with the inventory.
- Saves the updated inventory as
inventory.yml. - Exports merged variables for each host into the
merged_varsdirectory.
This code processes Ansible configurations into merged YAML inventories and generates Nix configuration files.
-
ansible/inventory/hosts.ini: Ansible inventory file. -
ansible/cmdb: Directory containing host facts.
-
autoconf/inventory.yml: Complete inventory with merged host facts. -
autoconf/merged_vars: Per-host.ymlfiles. -
nix_out: Directory containing Nix configuration files.
- Logs errors for missing files or directories.
- Warns about invalid host variables.
The script can run using command: python autoconf-pipeline.py in scripts/autoconf-pipeline.py
- Installation Guide - NixOS and Setting Up Luxnix
- Flake.nix & Garbage Collection
- Access Management
- Roles
- LX Cheatsheet
- tmux CLI Cheatsheet
- Deployment Guide
- Development
- Hardware Setup
- Network Architecture
- Security Improvements
- Security
- Service Architecture
- User Management
- Systemd tmpfiles Rules in NixOS
- Common Errors
- NixOs Configuration Testing with Eval
- System Language Change
- Roles Documentation
- Doc Maintenance Schedule
- Luxnix Server Setup with example
- Postgres Config Guide
- Postgres Documentation
- Postgres gc-10 Declarative Setup Summary
- Endoreg Central Architecture
- Readme
- Ansible CMDB Readme
- Process flow of creating Hosts, Roles, Groups
- Adding a New User Configuration
- Maintenance & Security: Auto Update #6
- Home Configuration Autoconf Flow (Step-by-Step)
- Guide to Define New Setting With Example
- Autoconfig- create inventory.yml using Python Script
- Updated : Generating home config files using autoconfig
- git
- vscode
- fix_long_lines
- kernel
- keycloak-setup
- network
- setup-mail
- setup-s04
- syncthing
- 2025-01-29 - postgres