Documentation ¶
Index ¶
- type Directive
- type Group
- type Host
- type Inventory
- func (i *Inventory) GetDirectives() []Directive
- func (i *Inventory) GetDirectivesForHost(host string) []Directive
- func (i *Inventory) GetDirectivesForSelf() []Directive
- func (i *Inventory) GetGroup(group string) (Group, bool)
- func (i *Inventory) GetGroups() []Group
- func (i *Inventory) GetHost(host string) (Host, bool)
- func (i *Inventory) GetHostname() string
- func (i *Inventory) GetHosts() []Host
- func (i *Inventory) GetInventoryPath() string
- func (i *Inventory) GetModule(module string) (Module, bool)
- func (i *Inventory) GetModules() []Module
- func (i *Inventory) GetModulesForGroup(group string) []Module
- func (i *Inventory) GetModulesForHost(host string) []Module
- func (i *Inventory) GetModulesForRole(role string) []Module
- func (i *Inventory) GetModulesForSelf() []Module
- func (i *Inventory) GetRole(role string) (Role, bool)
- func (i *Inventory) GetRoles() []Role
- func (i *Inventory) GetRolesForGroup(group string) []Role
- func (i *Inventory) GetRolesForHost(host string) []Role
- func (i *Inventory) GetRolesForSelf() []Role
- func (i *Inventory) GetVariablesForGroup(group string) string
- func (i *Inventory) GetVariablesForHost(host string) string
- func (i *Inventory) GetVariablesForSelf() []string
- func (i *Inventory) IsEnrolled() bool
- func (i *Inventory) ParseDirectives(ctx context.Context, logger *slog.Logger) error
- func (i *Inventory) ParseGroups(ctx context.Context, logger *slog.Logger) error
- func (i *Inventory) ParseHosts(ctx context.Context, logger *slog.Logger) error
- func (i *Inventory) ParseModules(ctx context.Context, logger *slog.Logger) error
- func (i *Inventory) ParseRoles(ctx context.Context, logger *slog.Logger) error
- func (i *Inventory) Reload(ctx context.Context, logger *slog.Logger)
- func (i *Inventory) String() string
- type Module
- type Role
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Directive ¶ added in v0.0.4
type Directive struct {
ID string
}
Directive contains fields that are relevant specifically to directive scripts, which are only executed if their modification time is within the last 24h Directive contains fields that represent a script in the inventory's directives directory. These scripts are executed first when changes are detected in the inventory, if and only if the script has a modification time within the last 24h. - ID: string idenitfying the directive script (generally the file path to the script)
type Group ¶ added in v0.7.0
type Group struct {
// contains filtered or unexported fields
}
Group contains fields that represent a given group of groups in the inventory. - id: string idenitfying the group - globs: a slice of glob patterns to match against the instance's hostname - patterns: a slice of regex patterns to match against the instance's hostname - roles: a slice of roles that are applied to this host - modules: a slice of ad-hoc module names applied to this host - variables: path to the variables file for this group, if present
func (Group) IsHostEnrolled ¶ added in v0.7.0
func (Group) MatchGlobs ¶ added in v0.7.0
func (Group) MatchPatterns ¶ added in v0.7.0
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host contains fields that represent a given host in the inventory. - id: string idenitfying the host (generally the hostname of the system) - roles: a slice of roles that are applied to this host - modules: a slice of ad-hoc module names applied to this host - variables: path to the variables file for this host, if present
type Inventory ¶
type Inventory struct {
// contains filtered or unexported fields
}
Inventory contains fields that comprise the data that makes up our inventory. - Hosts: a slice of `Host` structs for each parsed host - Modules: a slice of `Module` structs for each parsed module - Roles: a slice of `Role` structs for each parsed role - Directives: a slice of `Directive` structs, containing for each parsed directive - Groups: a slice of `Group` structs, containing globs/patterns for hostname matching
func NewInventory ¶
NewInventory parses the files/directories in the provided path to populate the inventory.
func (*Inventory) GetDirectives ¶
GetDirectives returns a copy of the inventory's slice of Directive
func (*Inventory) GetDirectivesForHost ¶
GetDirectivesForHost returns a copy of the inventory's slice of Directive. Since directives are applied to all hosts, this internally just calls `inventory.GetDirectives()`
func (*Inventory) GetDirectivesForSelf ¶
GetDirectivesForSelf returns a copy of the inventory's slice of Directive. Since directives are applied to all hosts, this internally just calls `inventory.GetDirectives()`
func (*Inventory) GetGroup ¶ added in v0.7.0
GetGroup returns a copy of the Group struct for a system identified by `group` name, and a boolean indicating whether or not the named group was found in the inventory.
func (*Inventory) GetHost ¶
GetHost returns a copy of the Host struct for a system identified by `host` name, and a boolean indicating whether or not the named host was found in the inventory.
func (*Inventory) GetHostname ¶ added in v0.2.0
GetHostname returns the inventory path as a string
func (*Inventory) GetInventoryPath ¶ added in v0.2.0
GetInventoryPath returns the inventory path as a string
func (*Inventory) GetModule ¶
GetModule returns a copy of the Module struct for a module identified by `module`, and a boolean indicating whether or not the named module was found in the inventory.
func (*Inventory) GetModules ¶
GetModules returns a copy of the inventory's Modules.
func (*Inventory) GetModulesForGroup ¶ added in v0.7.0
GetModulesForGroup returns a slice of Modules, containing all of the Modules for the specified host system (including modules in all assigned roles, as well as ad-hoc modules).
func (*Inventory) GetModulesForHost ¶
GetModulesForHost returns a slice of Modules, containing all of the Modules for the specified host system (including modules in all assigned roles, as well as ad-hoc modules).
func (*Inventory) GetModulesForRole ¶
GetModulesForRole returns a slice of Modules, containing all of the Modules for the specified role.
func (*Inventory) GetModulesForSelf ¶
GetModulesForSelf returns a slice of Modules, containing all of the Modules for the running system from the inventory.
func (*Inventory) GetRole ¶
GetRole returns a copy of the Role struct for a role identified by `role`. If the named role is not found in the inventory, an empty Role is returned.
func (*Inventory) GetRolesForGroup ¶ added in v0.7.0
func (*Inventory) GetRolesForHost ¶
GetRolesForHost returns a slice of Roles, containing all of the Roles for the specified host system.
func (*Inventory) GetRolesForSelf ¶
GetRolesForSelf returns a slice of Roles, containing all of the Roles for the running system from the inventory.
func (*Inventory) GetVariablesForGroup ¶ added in v0.7.0
GetVariablesForGroup returns the path of the group's variables file, or the empty string if no group/variables file found
func (*Inventory) GetVariablesForHost ¶
GetVariablesForHost returns the path of the host's variables file, or the empty string if no host/variables file found
func (*Inventory) GetVariablesForSelf ¶
GetVariablesForSelf returns slice of strings, containing the paths of any variables files found for this host. All group variables a provided first, with host-specific variables provided last (to allow for overriding default group variable data).
func (*Inventory) IsEnrolled ¶
IsEnrolled returns if the hostname of the system is defined in the inventory, or if the hostname of the system matches any group match parameters
func (*Inventory) ParseDirectives ¶
ParseDirectives looks for scripts in the inventory's `directives/` folder and adds them
func (*Inventory) ParseGroups ¶ added in v0.7.0
ParseGroups looks for groups in the inventory's `groups/` folder. It looks for folders within this directory, and then parses each directory into a Group struct. Each Group folder may contain a file `glob` containing a newline separated list of glob matches, and a `regex` file containing regular expression patterns for comparing groupnames.
func (*Inventory) ParseHosts ¶
ParseHosts looks for hosts in the inventory's `hosts/` folder. It looks for folders within this directory, and then parses each directory into a Host struct. Each host folder is expected to contain files for `apply`, `variables`, and `test`, which get set to the corresponding fields in the Host struct for the host.
func (*Inventory) ParseModules ¶
ParseModules looks for modules in the inventory's `modules/` folder. It looks for folders within this directory, and then parses each directory into a Module struct. Each module folder is expected to contain files for `apply`, `variables`, and `test`, which get set to the corresponding fields in the Module struct for the module.
func (*Inventory) ParseRoles ¶
ParseRoles searches for directories in the provided path. Each directory is treated as a role -- each role is checked for the appropriate `modules` file to parse for the list of modules for the role.
type Module ¶
Module contains fields that represent a single module in the inventory. - ID: string idenitfying the module (generally the file path to the module) - Apply: path to apply script for the module - Variables: path to variables file for the module, if present - Requires: path to requirements file for the module, if present - Test: path to test script to check module's application status
type Role ¶
type Role struct {
// contains filtered or unexported fields
}
Role contains fields that represent a single role in the inventory. - ID: string idenitfying the role (generally the file path to the role) - Modules: a []string of module names that satisfy this role
type Store ¶
type Store interface { // Inventory management functions Reload(ctx context.Context, logger *slog.Logger) // Enrollment and runtime/metadata checks IsEnrolled() bool GetInventoryPath() string GetHostname() string // General Inventory Getters GetDirectives() []Directive GetHosts() []Host GetModules() []Module GetRoles() []Role GetGroups() []Group // Inventory checks by component IDs GetHost(host string) (Host, bool) GetModule(module string) (Module, bool) GetRole(role string) (Role, bool) GetGroup(group string) (Group, bool) // Checks by host GetDirectivesForHost(host string) []Directive GetModulesForRole(role string) []Module GetModulesForHost(host string) []Module GetRolesForHost(host string) []Role GetVariablesForHost(host string) string // Self checks GetDirectivesForSelf() []Directive GetModulesForSelf() []Module GetRolesForSelf() []Role GetVariablesForSelf() []string }
Store is the set of methods that Inventory must implement to serve as a backing store for an inventory implementation. This is to try and keep a consistent API in the event that other inventory types are introduced, as well as to keep the required methods centralized if new features are introduced.