parser

package
v0.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: LGPL-2.1 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchGroups

func MatchGroups(groups map[string]*Group, pattern string) (map[string]*Group, error)

MatchGroups looks for groups that match the pattern

func MatchHosts

func MatchHosts(hosts map[string]*Host, pattern string) (map[string]*Host, error)

MatchHosts looks for hosts that match the pattern

func MatchVars

func MatchVars(vars map[string]string, pattern string) (map[string]string, error)

MatchVars looks for vars 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) Parse

func (dl *DataLoader) Parse(r io.Reader) error

Parse using some Reader

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

func GroupMapListValues(mymap map[string]*Group) []*Group

GroupMapListValues transforms map of Groups into Group list in lexical order

func (*Group) ListParentGroupsOrdered

func (group *Group) ListParentGroupsOrdered() []*Group

ListParentGroupsOrdered returns all ancestor groups of a given group in level order

func (*Group) MarshalJSON

func (group *Group) MarshalJSON() ([]byte, error)

func (*Group) MatchGroupsOrdered

func (group *Group) MatchGroupsOrdered(pattern string) ([]*Group, error)

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

func (group *Group) MatchHosts(pattern string) (map[string]*Host, error)

MatchHosts looks for hosts that match the pattern

func (*Group) MatchVars

func (group *Group) MatchVars(pattern string) (map[string]string, error)

MatchVars looks for vars that match the pattern

func (*Group) String

func (group *Group) String() string

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

func HostMapListValues(mymap map[string]*Host) []*Host

HostMapListValues transforms map of Hosts into Host list in lexical order

func (*Host) ListGroupsOrdered

func (host *Host) ListGroupsOrdered() []*Group

ListGroupsOrdered returns all ancestor groups of a given host in level order

func (*Host) MarshalJSON

func (host *Host) MarshalJSON() ([]byte, error)

func (*Host) MatchGroups

func (host *Host) MatchGroups(pattern string) (map[string]*Group, error)

MatchGroups looks for groups that match the pattern

func (*Host) MatchGroupsOrdered

func (host *Host) MatchGroupsOrdered(pattern string) ([]*Group, error)

MatchGroupsOrdered looks for groups that match the pattern The result is a sorted array, where lower indexes corespond to more specific groups

func (*Host) MatchVars

func (host *Host) MatchVars(pattern string) (map[string]string, error)

MatchVars looks for vars that match the pattern

func (*Host) String

func (host *Host) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL