Skip to content

Process flow of creating Hosts, Roles, Groups

Hamzaukw edited this page Sep 8, 2025 · 1 revision

Ansible Inventory

How LuxNix uses Ansible to manage hosts, roles, configurations, and services is explained and documented in user-management.md file.

Process Flow for Creating Hosts, Roles, Groups, Services, and Configurations

A. Adding a New Host ( user-management.md)

  1. Add the Host to Inventory:
    • Edit inventory/hosts.ini and assign the new host to a group.
  2. Define Host-Specific Variables:
    • Create a new file in inventory/host_vars/ named <hostname>.yml.
    • Include any special configurations (e.g., kernel, disk, GPU settings) that apply to this host.
  3. Group-Level Configurations (if needed):
    • If the host inherits configurations from its group, update inventory/group_vars/<group>.yml.
  4. Merged Variables:
    • Validate that merged_vars/<hostname>.yml correctly reflects the combined settings.
  5. Deployment:
    • Run: devenv tasks run autoconf:finished

B. How to Add Roles & Services in LuxNix Ansible Setup

  1. Enable a role in group settings (inventory/group_vars/<group>.yaml)
    • If a role should be enabled for all hosts in a group, define the role in this file.
  2. Enable a role for a specific host
    • If a role should apply only to a particular host, define it in the host's specific configuration file (inventory/host_vars/<hostname>.yml).
  3. Define additional role-specific configurations (luxnix/autoconf/group_vars.yml)
    • Some roles require extra parameters; these are set in a dedicated configuration file that maps roles to their required settings.
  4. Enable services using host_services(ansible/inventory/host_vars/) or group_services(ansible/inventory/group_vars/)
    • Services can be enabled at either the host level (specific to one machine) or group level (applied to all machines in the group).
  5. Deploy the updated configuration
    • After defining the roles and services, run the deployment command to apply them.

C. How to Add a New Group in LuxNix Ansible Setup

1. Define the Group in hosts.ini

  • Add a new group section and list the hosts etc under it (inventory/hosts.ini)
  • This step ensures that Ansible recognizes the new group and applies configurations to its hosts.
  • Built the configuration files by running ("bnsc"). If bnsc doen't work, then first run direnv allow.

2. Create Group-Specific Configuration

  • Define a new file to store the group's variables (inventory/group_vars/<new_group>.yaml)
  • This file will hold configurations that apply to all hosts in the group. For example:
  • group_roled:{}
  • group_services:{}
  • group_luxnix:{}

3. Set Up Group Roles & Services

  • Enable roles and services at the group level by adding relevant variables (inventory/group_vars/<new_group>.yaml)
  • Define which roles and services should be active for the entire group.
  • Rebuild rebiuld nix config,merged_vars and inventory.yml will be generated automatically.
  • Roles need to be add in systems/x86_64-linux/relevant_host file/default.nix

4. Ensure Any Required Global Overrides

  1. If necessary, update the global configuration to include defaults for the new group (luxnix/autoconf/group_vars.yml)
  2. This file can be used to provide default settings for the new group.

5. Deployment

For deployment run-ansible

D. How to Add Configurations in LuxNix Ansible Setup

1. Define Group-Level Configurations

  • Add configurations that apply to all hosts in the group.
  • Path: inventory/group_vars/<new_group>.yaml
  • This file stores variables for the group, such as system settings, network configurations, package management, etc.

2. Override or Extend Configurations at the Host Level

  • If specific hosts within the group need unique configurations, update their individual settings.
  • Path: inventory/host_vars/<hostname>.yml
  • This ensures that a host can have additional settings on top of the group defaults.

3. Modify Global Defaults if Necessary

  • If the new group requires default values for certain configurations, update the global variables file.
  • Path: luxnix/autoconf/group_vars.yml
  • This file provides base settings, which can be overridden at the group or host level.

5. Deploy and Apply the New Configuration

  • Run the appropriate deployment command to apply all new settings.

Clone this wiki locally