ansible

package module
v0.0.0-...-87b993e Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(f string) bool

FileExists checks if file exists

func MapKeys

func MapKeys[T string, V any](data map[string]V) []string

MapKeys returns map keys only

func Uniq

func Uniq(slice []string) []string

Uniq removes duplicates from slice

func Unquote

func Unquote(s string) string

Unquote is wrapper around strconv.Unquote, but will return unmodified input string on error

Types

type AnsibleCfg

type AnsibleCfg struct {
	Config map[string]map[string]string
}

func NewAnsibleCfgFile

func NewAnsibleCfgFile(f string) (*AnsibleCfg, error)

func NewAnsibleCfgParser

func NewAnsibleCfgParser(input []byte) *AnsibleCfg

type Host

type Host struct {
	Vars       HostVars // host vars
	Dirs       []string
	Files      map[string]string
	Group      string   // main group
	Groups     []string // all related groups
	Name       string   // host name
	Host       string   // host address
	Port       int      // host port
	User       string   // host user
	SSHPass    string   // host ssh password
	BecomePass string   // host become password
	PrivateKey string   // host ssh private key
	OrderedAt  string
}

Host is a parsed host

func MergeHost

func MergeHost(base, add *Host) *Host

func (*Host) FindFile

func (h *Host) FindFile(name string) (string, bool)

func (*Host) HasTODOs

func (h *Host) HasTODOs() bool

HasTODOs returns true if host has any todo values

type HostVars

type HostVars map[string]any

func NewHostVarsFile

func NewHostVarsFile(f string) (HostVars, error)

func NewHostVarsParser

func NewHostVarsParser(input []byte) (HostVars, error)

func (HostVars) Admin

func (hv HostVars) Admin() string

Admin parses admin MXID

func (HostVars) Admins

func (hv HostVars) Admins() []string

Admins parses admin MXIDs

func (HostVars) Bool

func (hv HostVars) Bool(key string) *bool

Bool returns bool value

func (HostVars) Domain

func (hv HostVars) Domain() (base, domain string)

Domain returns base domain (if exists) and domain

func (HostVars) Email

func (hv HostVars) Email() string

Email returns email

func (HostVars) Emails

func (hv HostVars) Emails() []string

Emails returns all emails

func (HostVars) FQN

func (hv HostVars) FQN(key string) string

FQN attempts to parse FQN var and replaces {{ matrix_domain }}, {{ base_domain }}, etc.

func (HostVars) HasTODOs

func (hv HostVars) HasTODOs() bool

HasTODOs returns true if there are any TODOs in hostvars

func (HostVars) IsAdmin

func (hv HostVars) IsAdmin(input string) bool

IsAdmin checks if provided input is server admin

func (HostVars) MaintenanceBranch

func (hv HostVars) MaintenanceBranch() string

MaintenanceBranch returns docker tag

func (HostVars) MaintenanceEnabled

func (hv HostVars) MaintenanceEnabled() bool

MaintenanceEnabled returns bool

func (HostVars) OSGroup

func (hv HostVars) OSGroup() string

func (HostVars) OSPath

func (hv HostVars) OSPath() string

func (HostVars) OSUser

func (hv HostVars) OSUser() string

func (HostVars) String

func (hv HostVars) String(key string, optionalDefault ...string) string

String returns string value

func (HostVars) StringSlice

func (hv HostVars) StringSlice(key string) []string

StringSlice returns string slice value

func (HostVars) Yes

func (hv HostVars) Yes(missing bool, key string) bool

Yes returns true if value is true (bool, string) or missing (if missing = true)

type Inventory

type Inventory struct {
	Groups    map[string][]*Host           // host-by-group
	GroupVars map[string]map[string]string // group vars
	GroupTree map[string][]string          // raw group tree
	Hosts     map[string]*Host             // hosts-by-name
	// contains filtered or unexported fields
}

Inventory contains all hosts file content

func NewHostsFile

func NewHostsFile(f string, defaults *Host, only ...string) (*Inventory, error)

func NewHostsParser

func NewHostsParser(input []byte, defaults *Host, only ...string) *Inventory

func ParseInventory

func ParseInventory(ansibleCfg, hostsini, limit string) *Inventory

ParseInventory using ansible.cfg and hosts (ini) files

func (*Inventory) Match

func (i *Inventory) Match(m string) *Host

Match a host by name

func (*Inventory) Merge

func (i *Inventory) Merge(h2 *Inventory)

Merge does append and replace

type LineType

type LineType int
const (
	TypeIgnore        LineType = iota // Line to ignore
	TypeVar           LineType = iota // Line contains var (key=value pair)
	TypeHost          LineType = iota // Line contains host (name key1=value1 key2=value2 ...)
	TypeGroup         LineType = iota // Line contains group ([group])
	TypeGroupVars     LineType = iota // Line contains group vars ([group:vars])
	TypeGroupChild    LineType = iota // Line contains group child (group_child)
	TypeGroupChildren LineType = iota // Line contains group children ([group_children])
)

Jump to

Keyboard shortcuts

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