pyinfra.api.inventory module¶
- class pyinfra.api.inventory.Inventory(names_data, override_data=None, **groups)¶
Bases:
object
Represents a collection of target hosts. Stores and provides access to group data, host data and default data for these hosts.
- Parameters
names_data – tuple of
(names, data)
override_data – dictionary of data overrides
ssh_* – deprecated, use
override_data.ssh_*
winrm_* – deprecated, use
override_data.winrm_*
**groups – map of group name ->
(names, data)
- static empty()¶
- get_data()¶
Get the base/all data attached to this inventory.
- get_group(name: str, default=<class 'pyinfra.api.exceptions.NoGroupError'>)¶
Get a list of hosts belonging to a group.
- get_group_data(group)¶
Get data for a single group in this inventory.
- get_groups_data(groups)¶
Gets aggregated data from a list of groups. Vars are collected in order so, for any groups which define the same var twice, the last group’s value will hold.
- get_host(name: str, default=<class 'pyinfra.api.exceptions.NoHostError'>)¶
Get a single host by name.
- get_host_data(hostname: str)¶
Get data for a single host in this inventory.
- get_override_data()¶
Get override data for this inventory.
- len_activated_hosts() int ¶
Returns the number of activated inventory hosts.
- len_active_hosts() int ¶
Returns the number of active inventory hosts.
- make_hosts_and_groups(names, groups) None ¶
- pyinfra.api.inventory.extract_name_data(names: list[Any])¶