Documentation ¶
Index ¶
- func MatchGroups(groups map[string]*Group, pattern string) (map[string]*Group, error)
- func MatchHosts(hosts map[string]*Host, pattern string) (map[string]*Host, error)
- func MatchVars(vars map[string]string, pattern string) (map[string]string, error)
- type DataLoader
- func (dl *DataLoader) AddVars(path string) error
- func (dl *DataLoader) AddVarsLowerCased(path string) error
- func (dl *DataLoader) GroupsToLower()
- func (dl *DataLoader) HostsToLower()
- func (dl *DataLoader) MatchGroups(pattern string) (map[string]*Group, error)
- func (dl *DataLoader) MatchHosts(pattern string) (map[string]*Host, error)
- func (dl *DataLoader) Parse(r io.Reader) error
- func (dl *DataLoader) ParseFile(f string) error
- func (dl *DataLoader) ParseString(input string) error
- func (dl *DataLoader) Reconcile()
- func (dl *DataLoader) UnmarshalJSON(data []byte) error
- type Group
- func (group *Group) ListParentGroupsOrdered() []*Group
- func (group *Group) MarshalJSON() ([]byte, error)
- func (group *Group) MatchGroupsOrdered(pattern string) ([]*Group, error)
- func (group *Group) MatchHosts(pattern string) (map[string]*Host, error)
- func (group *Group) MatchVars(pattern string) (map[string]string, error)
- func (group *Group) String() string
- type Host
- func (host *Host) ListGroupsOrdered() []*Group
- func (host *Host) MarshalJSON() ([]byte, error)
- func (host *Host) MatchGroups(pattern string) (map[string]*Group, error)
- func (host *Host) MatchGroupsOrdered(pattern string) ([]*Group, error)
- func (host *Host) MatchVars(pattern string) (map[string]string, error)
- func (host *Host) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchGroups ¶
MatchGroups looks for groups that match the pattern
func MatchHosts ¶
MatchHosts looks for hosts that match the pattern
Types ¶
type DataLoader ¶
type DataLoader struct { Groups map[string]*Group Hosts map[string]*Host // contains filtered or unexported fields }
DataLoader contains parsed inventory representation Note: Groups and Hosts fields contain all the groups and hosts, not only top-level
func NewDataLoader ¶
func NewDataLoader() *DataLoader
func (*DataLoader) AddVars ¶
func (dl *DataLoader) AddVars(path string) error
AddVars take a path that contains group_vars and host_vars directories and adds these variables to the DataLoader
func (*DataLoader) AddVarsLowerCased ¶
func (dl *DataLoader) AddVarsLowerCased(path string) error
AddVarsLowerCased does the same as AddVars, but converts hostnames and groups name to lowercase. Use this function if you've executed `inventory.HostsToLower` or `inventory.GroupsToLower`
func (*DataLoader) GroupsToLower ¶
func (dl *DataLoader) GroupsToLower()
GroupsToLower transforms all group names to lowercase
func (*DataLoader) HostsToLower ¶
func (dl *DataLoader) HostsToLower()
HostsToLower transforms all host names to lowercase
func (*DataLoader) MatchGroups ¶
func (dl *DataLoader) MatchGroups(pattern string) (map[string]*Group, error)
MatchGroups looks for groups that match the pattern
func (*DataLoader) MatchHosts ¶
func (dl *DataLoader) MatchHosts(pattern string) (map[string]*Host, error)
MatchHosts looks for hosts that match the pattern
func (*DataLoader) ParseFile ¶
func (dl *DataLoader) ParseFile(f string) error
ParseFile parses DataLoader represented as a file
func (*DataLoader) ParseString ¶
func (dl *DataLoader) ParseString(input string) error
ParseString parses DataLoader represented as a string
func (*DataLoader) Reconcile ¶
func (dl *DataLoader) Reconcile()
Reconcile ensures inventory basic rules, run after updates. After initial inventory file processing, only direct relationships are set.
This method:
- (re)sets Children and Parents for hosts and groups
- ensures that mandatory groups exist
- calculates variables for hosts and groups
func (*DataLoader) UnmarshalJSON ¶
func (dl *DataLoader) UnmarshalJSON(data []byte) error
type Group ¶
type Group struct { Name string Vars map[string]string Hosts map[string]*Host Children map[string]*Group Parents map[string]*Group DirectParents map[string]*Group // Vars set in inventory InventoryVars map[string]string // Vars set in group_vars FileVars map[string]string // Projection of all parent inventory variables AllInventoryVars map[string]string // Projection of all parent group_vars variables AllFileVars map[string]string }
Group represents ansible group
func GroupMapListValues ¶
GroupMapListValues transforms map of Groups into Group list in lexical order
func (*Group) ListParentGroupsOrdered ¶
ListParentGroupsOrdered returns all ancestor groups of a given group in level order
func (*Group) MarshalJSON ¶
func (*Group) MatchGroupsOrdered ¶
MatchGroupsOrdered looks for groups that match the pattern The result is a sorted array, where lower indexes corespond to more specific groups
func (*Group) MatchHosts ¶
MatchHosts looks for hosts that match the pattern
type Host ¶
type Host struct { Name string Port int Vars map[string]string Groups map[string]*Group DirectGroups map[string]*Group // Vars set in inventory InventoryVars map[string]string // Vars set in host_vars FileVars map[string]string }
Host represents ansible host
func HostMapListValues ¶
HostMapListValues transforms map of Hosts into Host list in lexical order
func (*Host) ListGroupsOrdered ¶
ListGroupsOrdered returns all ancestor groups of a given host in level order
func (*Host) MarshalJSON ¶
func (*Host) MatchGroups ¶
MatchGroups looks for groups that match the pattern
func (*Host) MatchGroupsOrdered ¶
MatchGroupsOrdered looks for groups that match the pattern The result is a sorted array, where lower indexes corespond to more specific groups