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 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
- type InventoryData
- func (inventory *InventoryData) AddVars(path string) error
- func (inventory *InventoryData) AddVarsLowerCased(path string) error
- func (inventory *InventoryData) GroupsToLower()
- func (inventory *InventoryData) HostsToLower()
- func (inventory *InventoryData) Match(pattern string) []*Host
- func (inventory *InventoryData) MatchGroups(pattern string) (map[string]*Group, error)
- func (inventory *InventoryData) MatchHosts(pattern string) (map[string]*Host, error)
- func (inventory *InventoryData) Reconcile()
- func (inventory *InventoryData) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchGroups ¶ added in v1.4.0
MatchGroups looks for groups that match the pattern
func MatchHosts ¶ added in v1.4.0
MatchHosts looks for hosts that match the pattern
Types ¶
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 ¶ added in v1.1.0
GroupMapListValues transforms map of Groups into Group list in lexical order
func (*Group) ListParentGroupsOrdered ¶ added in v1.5.0
ListParentGroupsOrdered returns all ancestor groups of a given group in level order
func (*Group) MarshalJSON ¶ added in v1.6.0
func (*Group) MatchGroupsOrdered ¶ added in v1.5.0
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 ¶ added in v1.4.0
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 ¶ added in v1.1.0
HostMapListValues transforms map of Hosts into Host list in lexical order
func (*Host) ListGroupsOrdered ¶ added in v1.5.0
ListGroupsOrdered returns all ancestor groups of a given host in level order
func (*Host) MarshalJSON ¶ added in v1.6.0
func (*Host) MatchGroups ¶ added in v1.4.0
MatchGroups looks for groups that match the pattern
func (*Host) MatchGroupsOrdered ¶ added in v1.5.0
MatchGroupsOrdered looks for groups that match the pattern The result is a sorted array, where lower indexes corespond to more specific groups
type InventoryData ¶
InventoryData contains parsed inventory representation Note: Groups and Hosts fields contain all the groups and hosts, not only top-level
func ParseFile ¶
func ParseFile(f string) (*InventoryData, error)
ParseFile parses Inventory represented as a file
func ParseString ¶
func ParseString(input string) (*InventoryData, error)
ParseString parses Inventory represented as a string
func (*InventoryData) AddVars ¶ added in v1.3.0
func (inventory *InventoryData) AddVars(path string) error
AddVars take a path that contains group_vars and host_vars directories and adds these variables to the InventoryData
func (*InventoryData) AddVarsLowerCased ¶ added in v1.3.0
func (inventory *InventoryData) 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 (*InventoryData) GroupsToLower ¶ added in v1.2.0
func (inventory *InventoryData) GroupsToLower()
GroupsToLower transforms all group names to lowercase
func (*InventoryData) HostsToLower ¶ added in v1.2.0
func (inventory *InventoryData) HostsToLower()
HostsToLower transforms all host names to lowercase
func (*InventoryData) Match ¶
func (inventory *InventoryData) Match(pattern string) []*Host
Match looks for hosts that match the pattern Deprecated: Use `MatchHosts`, which does proper error handling
func (*InventoryData) MatchGroups ¶ added in v1.4.0
func (inventory *InventoryData) MatchGroups(pattern string) (map[string]*Group, error)
MatchGroups looks for groups that match the pattern
func (*InventoryData) MatchHosts ¶ added in v1.4.0
func (inventory *InventoryData) MatchHosts(pattern string) (map[string]*Host, error)
MatchHosts looks for hosts that match the pattern
func (*InventoryData) Reconcile ¶
func (inventory *InventoryData) 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 (*InventoryData) UnmarshalJSON ¶ added in v1.6.0
func (inventory *InventoryData) UnmarshalJSON(data []byte) error