Ansible Inventory Generator
{{ result.primary }}
{{ result.summaryLine }}
{{ badge.label }}
Ansible inventory inputs
Use the group name you will target in playbooks or ad hoc commands.
One host per line using alias,ansible_host,groups,host_vars. Blank lines and # comments are ignored.
{{ fileStatus || 'Drop CSV or TXT onto the textarea.' }}
{{ fileError }}
Keep the login user explicit when this inventory will be shared or committed.
Use plain Ansible inventory variables such as ansible_connection=ssh or ansible_network_os=cisco.ios.ios.
Leave blank when the primary group is the only target you need.
Sorting only changes generated output order; row numbers remain available in the ledger.
Adds a short header with the ansible-inventory verification command.
Usually off; enable only when you want a placeholder section for later editing.
{{ result.inventoryText || '# Fix validation errors to generate inventory.ini.' }}
Alias ansible_host Groups Host variables Source line Copy
No valid hosts parsed yet.
{{ host.alias }} {{ host.ansibleHost || host.alias }} {{ host.groups.join(', ') || '-' }} {{ host.hostVarText || '-' }} {{ host.lineNumber }}
Severity Check Detail Recommendation Copy
{{ row.severity }} {{ row.check }} {{ row.detail }} {{ row.recommendation }}
{{ formattedJson }}
Customize
Advanced
:

Introduction

An Ansible inventory tells automation which managed nodes exist, how they should be grouped, and which connection variables apply before a playbook runs. A small inventory can be typed by hand. A larger one is easier to review when host aliases, addresses, groups, and variables are captured in rows and then rendered into a consistent static INI inventory.

This generator turns host rows into a primary group, optional extra groups, optional group variables, and an optional parent children group. It is useful when a network, Linux, or mixed operations list already exists in spreadsheet-like form and needs to become an inventory.ini artifact with fewer copy mistakes.

The input row shape is compact: alias,ansible_host,groups,host_vars. Blank lines and lines beginning with # are ignored. The page can load CSV or text from your device, normalize valid rows back into the same row shape, sort by host alias when needed, and keep input order for rollout batches where sequence matters.

The generator is a formatter and review aid, not a live Ansible connection test. It does not contact the listed hosts, query DNS, or run ansible-inventory. Treat addresses, usernames, host variables, and connection details as operational data. Generation happens in the page, but current settings can appear in the page URL and in copied or downloaded outputs, so avoid putting secrets in host variables or group variables.

Technical Details

Ansible supports several inventory sources, but this generator focuses on a static INI inventory. In that format, a section such as [edge_routers] lists hosts in a group. A line can use the inventory alias as the managed-node name and attach variables such as ansible_host=10.44.1.11, ansible_port=2222, or role=edge. A separate [edge_routers:vars] section applies variables to every host in the primary group.

The primary group is required because it becomes the first inventory section and the main playbook target. The page accepts extra groups in each host row and places each alias into those group sections as well. When a parent children group is entered, the output adds a [parent:children] section containing the primary group and every extra group found in the parsed rows. That gives a larger target name without duplicating every host line under the parent.

Host rows alias, address extra groups host variables Inventory builder validate aliases check group names merge group vars assemble INI sections record review notes Outputs INI inventory host ledger review table and JSON
Rows become inventory sections only after the page checks the group name, host aliases, variables, duplicates, and optional parent grouping.

CSV handling is deliberately small and predictable. The page reads each non-comment line as comma-separated cells, supports quoted cells, and treats a recognizable header row as labels instead of a host. Extra groups can be separated with spaces, pipes, or semicolons. Host variables are read as whitespace-separated key=value tokens, with quoted values supported when a value contains spaces. Group variables use one key=value entry per line.

Variable rules are stricter than plain text because Ansible variable names should be usable identifiers. Keys must start with a letter or underscore and then use letters, numbers, or underscores. The same rule is used for group variable names and host variable names. The default ansible_user field is inserted into group variables unless group variables already include ansible_user; in that duplicate case the page warns and keeps the explicit group variable as the source of truth.

Inventory Assembly Map

Ansible inventory generator assembly stages
Stage What the page reads What it emits Why it matters
Primary group Inventory group field [group] section This is the main target used from playbooks and ad hoc commands.
Host row parsing alias,ansible_host,groups,host_vars Host lines with optional ansible_host and host variables The alias becomes inventory_hostname; the address becomes the connection target when supplied.
Extra groups Third CSV cell split by spaces, pipes, or semicolons Additional group sections listing host aliases One host can be targeted by location, role, environment, or platform without repeating full host lines.
Parent children group Optional parent name [parent:children] section A metagroup can target the primary group and all discovered extra groups together.
Group variables Default user plus group variable lines [group:vars] entries Connection defaults can be kept once instead of repeated on every host line.
Review outputs Parsed hosts, checks, warnings, and errors Host ledger, inventory review, and JSON payload The generated inventory can be audited before it is copied into a repository or runbook.

Output Skeleton

# Static Ansible inventory generated by simplified.tools
# Verify with: ansible-inventory -i inventory.ini --list

[edge_routers]
edge-rtr-01 ansible_host=10.44.1.11 site=dc1 role=edge
edge-rtr-02 ansible_host=10.44.1.12 site=dc2 role=edge

[dc1]
edge-rtr-01

[dc2]
edge-rtr-02

[network:children]
edge_routers
dc1
dc2

[edge_routers:vars]
ansible_user=admin
ansible_connection=network_cli

Validation Rules

Ansible inventory generator validation behavior
Condition Page behavior What to do
Missing inventory group Raises an error and suppresses INI output Enter the group name that playbooks should target.
Group name contains whitespace, brackets, colon, or # Raises an error Use a compact group name such as prod_linux or edge_routers.
Group name is usable but not strict identifier style Adds a warning with a normalized suggestion Prefer letters, numbers, and underscores when the inventory will be shared widely.
Duplicate host alias Raises an error Keep each inventory alias unique because Ansible uses it as the host identity.
Host alias contains whitespace, brackets, or # Raises an error Put the real address in ansible_host and keep the alias compact.
Host variable or group variable is not key=value Raises an error Use one key and one value per token or line.
Alias has no separate ansible_host and does not look like a DNS name Adds a warning Add ansible_host when the alias is not directly resolvable.
Parent children group equals the primary group Raises an error Use a different metagroup name or leave the parent field empty.

Everyday Use & Decision Guide

Start by deciding what the inventory will target. Use the primary group for the playbook host pattern you expect to type most often. For network devices, that may be edge_routers, core_switches, or network_devices. For servers, it may be prod_linux, web, or db. A group name that already reads like a playbook target reduces confusion later.

Use extra groups for cross-cutting labels. A host can belong to dc1, prod, and ios while still living in the primary group. That is better than creating several separate inventories for the same devices. The generated group sections list aliases only, so the detailed host variables remain in one place.

Keep connection settings at the right level. Put shared values such as ansible_connection=ssh, ansible_connection=network_cli, ansible_python_interpreter=/usr/bin/python3, or ansible_network_os=cisco.ios.ios in group variables when they apply to the whole primary group. Put exceptions such as a nonstandard ansible_port or device-specific role in the host row.

  • Choose Network sample when the starting point is router or switch inventory with platform variables.
  • Choose Linux sample when the starting point is SSH-based server automation with Python interpreter defaults.
  • Use Normalize rows after paste or file load to rebuild valid rows in a cleaner order and remove ignored comments.
  • Use Sort by host alias for stable review diffs. Keep input order when rows represent a rollout sequence.
  • Keep Include verification comments enabled when the output will be handed to someone who should run ansible-inventory -i inventory.ini --list before use.
  • Enable an empty :vars section only when a placeholder is intentionally needed for later editing.

Do not use this page as a secret store. Static inventories often tempt people to paste passwords, tokens, or private keys into variables because INI accepts arbitrary text. Prefer vaulted variables, environment-specific variable files, or your normal secrets workflow. This generator can help shape an inventory, but it cannot protect a secret once it appears in page state, copied INI text, CSV exports, JSON exports, or screenshots.

Step-by-Step Guide

  1. Enter the primary Inventory group. Use the exact group you expect to reference from hosts: or an ad hoc command.
  2. Paste host rows or load a CSV or text file. Use alias,ansible_host,groups,host_vars, one host per line. Leave the address blank only when the alias itself can be resolved by Ansible.
  3. Put extra groups in the third cell when a host should also appear under locations, roles, operating systems, or environments. Separate those group names with spaces, pipes, or semicolons.
  4. Add host variables after the third comma. Use key=value tokens separated by spaces. Quote a value when it needs a space, then check the review table for quoting errors.
  5. Set Default ansible_user when one login should apply to the primary group. Add other shared defaults in Group variables, one key=value entry per line.
  6. Open Advanced if the output needs a parent children group, host alias sorting, verification comments, or a placeholder :vars section.
  7. Read any red errors before copying the INI output. The page intentionally suppresses the generated inventory when a blocking condition exists.
  8. Review yellow warnings before committing the result. A warning can still produce INI, but it points to something that may surprise Ansible or the next reviewer.
  9. Copy or download the INI Inventory, then run ansible-inventory -i inventory.ini --list in the environment where Ansible and its collections are installed.

Interpreting Results

The summary box gives a quick status: host count, primary group, and whether warnings exist. A host count does not prove that the inventory will connect successfully. It means the row parser accepted that many rows and the generator had enough information to build the INI artifact.

The INI Inventory tab is the copyable artifact. If errors exist, it shows a placeholder instead of an inventory because using partial automation input is riskier than fixing the rows first. When output is present, read the first group section, then scan extra group sections, parent children grouping, and the group variables section before copying.

The Host Ledger tab is often easier to review than raw INI. It separates alias, ansible_host, group membership, host variables, and source line. Use it to spot a wrong data center group, a missing address, a duplicated role, or a row that came from the wrong line in a pasted CSV.

The Inventory Review tab explains passes, warnings, and errors in plain rows. A pass means one check looks internally consistent. A warning means the page can still generate output but the resulting inventory deserves attention. An error means the page will not claim that a usable inventory exists.

How to use Ansible inventory generator result tabs
Result tab Best use Limit
INI Inventory Copying or downloading the static inventory text. It has not been parsed by your installed Ansible version.
Host Ledger Reviewing aliases, addresses, groups, variables, and source lines. It shows accepted rows only; rejected rows appear as review errors.
Inventory Review Finding why the output is blocked or why a warning remains. A clean review does not prove SSH, WinRM, or network CLI access works.
JSON Saving a structured snapshot of parsed hosts, groups, variables, output, and review rows. It is a handoff format, not an Ansible inventory format.

The final verification step belongs outside the page. Run Ansible's inventory parser, then run a harmless ping, facts, or platform-specific check against a small target set before using the inventory for a change.

Worked Examples

Network device inventory

Start with group edge_routers, use rows such as edge-rtr-01,10.44.1.11,dc1|ios,site=dc1 role=edge, set the default user to admin, and add group variables such as ansible_connection=network_cli and ansible_network_os=cisco.ios.ios. A parent group such as network then creates a target that includes edge_routers, dc1, and any other extra groups found in the rows.

The review should be checked for platform-variable spelling and group-name warnings. A clean generated INI still needs the right Ansible collection and credentials in the execution environment before network CLI tasks can run.

Linux web and database hosts

Use group prod_linux, add rows such as web-01,10.50.10.21,web|prod,site=dc1 role=frontend and db-01,10.50.20.31,db|prod,site=dc1 role=postgres ansible_port=2222, then set ansible_connection=ssh and ansible_python_interpreter=/usr/bin/python3 as group variables. The nonstandard database SSH port stays on the host row because it is not shared by every host.

Sorting by alias is helpful for this example when the generated inventory is reviewed in source control. If the rows represent a maintenance order, keep input order and use the host ledger to confirm the sequence.

Importing a spreadsheet export

A spreadsheet can be exported as CSV with columns for alias, address, groups, and variables. Load it through the file picker or drop it onto the row field, then use Normalize rows. The normalized output keeps accepted rows in the generator's expected shape and removes comments, blank lines, and header labels from the working text.

If the CSV contains descriptions, owner names, or ticket references, keep them out of host variables unless Ansible really needs them. Operational notes usually belong in documentation or a CMDB rather than in an inventory line that might be copied into a playbook repository.

FAQ

Does the generator test whether hosts are reachable?

No. It only parses rows, validates inventory text, and assembles outputs. Use ansible-inventory -i inventory.ini --list first, then a small connectivity check from the Ansible control node.

Can I leave ansible_host blank?

Yes, but only when the alias itself is the connection target Ansible should use. The page warns when a short alias has no separate address because names such as web-01 often are not resolvable outside local DNS or SSH configuration.

Why does the page warn about group names that Ansible might still accept?

Some names can parse but still create warnings or awkward variable-style references later. The generator prefers simple identifier-style group names made from letters, numbers, and underscores.

Should passwords be placed in host variables?

No. Static inventory text, browser URLs, exported files, and screenshots are poor places for secrets. Use your normal secrets workflow, such as vaulted variables or environment-specific protected files.

What is the difference between extra groups and a parent children group?

Extra groups place each host alias into additional group sections. A parent children group creates a metagroup that contains the primary group and those extra groups, so one parent target can refer to several group sections at once.

Glossary

Inventory alias
The name Ansible uses for the host inside inventory. It can differ from the address used for connection.
ansible_host
The DNS name or address Ansible should connect to when the alias is not the connection target.
Primary group
The main group section generated first and used as the default playbook target for this inventory.
Extra group
An additional group assigned from a host row, such as a data center, platform, role, or environment.
Group variables
Variables placed under a [group:vars] section so they apply to the whole primary group.
Parent children group
A metagroup section that lists other groups as children instead of listing individual hosts.