lia [-h] (--list|--host HOST)
Lia is a helper script to query hosts, groups, and variables from your LDAP server, and provide it to Ansible. Lia is highly configurable to support caching and adjust to any LDAP schema.
The program will cache the inventory in JSON format, and serve it until the cache expires.
Show usage information, and exit.
Print all groups and variables.
Print variables for the host HOST.
Returns zero if the inventory was retrieved.
Sets verbosity of logging sent to standard error. Recognized levels are:
CRITICAL
ERROR
WARNING
(default)INFO
DEBUG
-
$XDG_CONFIG_HOME/lia.json
-
~/.config/lia.json
-
$XDG_CACHE_HOME/lia.json
-
~/.cache/lia.json
The JSON structure in this file defines how lia connects to LDAP server, and what information it searches for.
One or more space-delimited URIs of the LDAP server.
Optional. Page size to request for search operations.
Default: 100.
Optional. Maximum age (in seconds) of the inventory cache at $XDG_CACHE_HOME/lia.json
or
~/.cache/lia.json
.
Default: 10800.
A dictionary defining how to search for hosts and which attributes to request.
A list of dictionaries, each defining how to search for groups, which attributes to request, and how to interpret host membership.
The node in LDAP, from which the search starts.
Optional. LDAP search scope, may only be sub for subtree search or any other value for base search. This is a limitation imposed by the ldap3 library abstraction objects.
Default: sub.
A list of object class names to search for.
A dictionary describing attributes to request. The following members are required.
The attribute containing host name (e.g. "cn").
If multiple values are returned for a single object (in other words, a host has multiple names), lia will pick the one in common with the RDN components.
If none of the values are in the RDN, use the first alphabetically.
For example:
LDAP object:
dn: cn=charlie,dc=example,dc=net
cn: charlie
cn: alpha
Host name: charlie
LDAP object:
dn: vCPU=2+cn=bravo,dc=example,dc=net
cn: bravo
cn: alpha
Host name: bravo
LDAP object:
dn: uuid=e035608b-cf04-4d2a-9451-0a7813c5225d,dc=example,dc=net
cn: bravo
cn: alpha
Host name: alpha
The attribute that holds JSON-formatted variables.
Group search criteria. See Members of hosts
Dictionary above.
A dictionary describing attributes to request. The following members are required:
Identical to the eponymous hosts
members, see above.
The attribute listing member hosts.
If true, then the attribute defined in host lists distinguished names of the member hosts. Otherwise, it lists host names.
{
"uri": "ldaps://ldap.example.org",
"page": 200,
"cache_time": 86400,
"hosts": {
"base": "ou=hosts,dc=example,dc=org",
"scope": "sub",
"objectclass": ["ansibleHost", "device"],
"attr": {
"name": "cn",
"var": "ansibleVars"
}
},
"groups": [
{
"base": "ou=ansible,ou=groups,dc=example,dc=org",
"scope": "sub",
"objectclass": ["groupOfNames", "ansibleGroup"],
"attr": {
"name": "cn",
"host": "member",
"host_is_dn": true,
"var": "ansibleVars"
}
},
{
"base": "ou=hosts,dc=example,dc=org",
"scope": "sub",
"objectclass": ["organizationalUnit", "ansibleGroup"],
"attr": {
"name": "ou",
"var": "ansibleVars"
}
}
]
}