Inventory
Spage has the ability to parse inventory through many different formats. The format described in this document is a result of closely following the Ansible inventory format.
Inventory file
The inventory file is a YAML file that contains the inventory for Spage.
all:
hosts:
localhost:
host: 127.0.0.1
my_var: "Host specific variable!"
my_group:
hosts:
localhost:
vars:
my_group_var: "Group specific variable!"
You can define variables specifically on a host or group level.
host_vars
and group_vars
Whenever an inventory file is specified through either the -i
flag or the inventory
configuration option, Spage will automatically load the host_vars
and group_vars
files.
Spage searches for host_vars
and group_vars
files in the same directory as the inventory file.
For example, take this file tree:
root/
├─ inventory.yaml
├─ host_vars/
│ ├── localhost.yaml
│ └── my_host.yaml
└─ group_vars/
└── my_group.yaml
Running spage inventory list -i root/inventory.yaml
will load the variables from the host_vars
and group_vars
directories.
Inventory plugins
Spage supports inventory plugins. These plugins are used to extend the inventory file format.
Ansible inventory plugin compatibility
Spage supports custom inventory plugins written to be used by Ansible. This does require the Python run-time fallback to be available on the host that runs Spage.
Spage Inventory CLI
You can also use the spage inventory list
command to list the hosts and their variables in the inventory.
$ spage inventory list -i my_inventory.yaml
{
"_meta": {
"hostvars": {}
},
"all": {
"hosts": [],
"vars": {
"dir_allgroup_var": "dir_allgroup_var_value",
"file_allgroup_var": "file_allgroup_var_value"
}
},
"somegroup": {
"hosts": [],
"vars": {
"dir_group_var": "dir_group_var_value",
"file_group_var": "file_group_var_value"
}
}
}