db

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inventory

type Inventory struct {
	Raw       []byte
	HostsRef  map[string]string `json:"host_refs,omitempty" yaml:"host_refs,omitempty"`
	GroupsRef map[string]bool   `json:"group_refs,omitempty" yaml:"group_refs,omitempty"`
	Hosts     []*InventoryHost  `json:"hosts,omitempty" yaml:"hosts,omitempty"`
	Groups    []*InventoryGroup `json:"groups,omitempty" yaml:"groups,omitempty"`
}

Inventory is the contents of Ansible inventory file.

func NewInventory

func NewInventory() *Inventory

NewInventory returns a pointer to Inventory.

func (*Inventory) AddGroup

func (inv *Inventory) AddGroup(s, p string) error

AddGroup adds a group to the Inventory.

func (*Inventory) AddGroupMemberCounter

func (inv *Inventory) AddGroupMemberCounter(counterType, groupName string) error

AddGroupMemberCounter increments group membership counters for hosts and sub-groups.

func (*Inventory) AddHost

func (inv *Inventory) AddHost(s, groupName string) error

AddHost adds a host to the Inventory.

func (*Inventory) AddVariable

func (inv *Inventory) AddVariable(s, groupName string) error

AddVariable adds a variable to an InventoryGroup.

func (*Inventory) GetGroup

func (inv *Inventory) GetGroup(s string) (*InventoryGroup, error)

GetGroup returns an instance of InventoryGroup.

func (*Inventory) GetHost

func (inv *Inventory) GetHost(s string) (*InventoryHost, error)

GetHost returns an instance of InventoryHost.

func (*Inventory) GetHosts

func (inv *Inventory) GetHosts() ([]*InventoryHost, error)

GetHosts returns a list of InventoryHost instances.

func (*Inventory) GetHostsWithFilter added in v1.0.5

func (inv *Inventory) GetHostsWithFilter(hostFilter, groupFilter interface{}) ([]*InventoryHost, error)

GetHostsWithFilter returns a list of InventoryHost instances filtered by input host and group patterns. Returns the host matching the patterns only.

func (*Inventory) GetParentGroup

func (inv *Inventory) GetParentGroup(s string) ([]string, error)

GetParentGroup gets parent inventory groups for the provided one.

func (*Inventory) GetParentGroupChains

func (inv *Inventory) GetParentGroupChains(s string) ([]string, []string, error)

GetParentGroupChains gets parent inventory groups recursively for the provided one.

func (*Inventory) LoadFromBytes

func (inv *Inventory) LoadFromBytes(b []byte) error

LoadFromBytes loads inventory data from an array of bytes.

func (*Inventory) LoadFromFile

func (inv *Inventory) LoadFromFile(fp string) error

LoadFromFile loads inventory data from a file.

func (*Inventory) Size

func (inv *Inventory) Size() uint64

Size returns the number of hosts in the Inventory.

type InventoryGroup

type InventoryGroup struct {
	Name      string                 `json:"name,omitempty" yaml:"name,omitempty"`
	Ancestors []string               `json:"parent_groups,omitempty" yaml:"parent_groups,omitempty"`
	Variables map[string]string      `json:"variables,omitempty" yaml:"variables,omitempty"`
	Counters  InventoryGroupCounters `json:"counters,omitempty" yaml:"counters,omitempty"`
}

InventoryGroup is an group of InventoryHost instances.

type InventoryGroupCounters added in v1.0.6

type InventoryGroupCounters struct {
	Hosts  uint64 `json:"hosts,omitempty" yaml:"hosts,omitempty"`
	Groups uint64 `json:"groups,omitempty" yaml:"groups,omitempty"`
}

InventoryGroupCounters are counters associated with InventoryGroup

type InventoryHost

type InventoryHost struct {
	Name        string            `json:"name,omitempty" yaml:"name,omitempty"`
	Parent      string            `json:"parent_group,omitempty" yaml:"parent_group,omitempty"`
	Variables   map[string]string `json:"variables,omitempty" yaml:"variables,omitempty"`
	Groups      []string          `json:"groups,omitempty" yaml:"groups,omitempty"`
	GroupChains []string          `json:"group_chains,omitempty" yaml:"group_chains,omitempty"`
}

InventoryHost is a host in Ansible inventory

type Vault

type Vault struct {
	Header      VaultHeader        `xml:"-" json:"-" yaml:"-"`
	Body        VaultBody          `xml:"-" json:"-" yaml:"-"`
	Key         VaultKey           `xml:"-" json:"-" yaml:"-"`
	Password    []byte             `xml:"-" json:"-" yaml:"-"`
	Payload     []byte             `xml:"-" json:"-" yaml:"-"`
	Credentials []*VaultCredential `xml:"credentials" json:"credentials" yaml:"credentials"`
}

Vault is the contents of Ansible vault file.

func NewVault

func NewVault() *Vault

NewVault returns a pointer to Vault.

func (*Vault) GetCredentials

func (v *Vault) GetCredentials(s string) ([]*VaultCredential, error)

GetCredentials returns a list of credential applicable to the provided host name.

func (*Vault) LoadFromBytes

func (v *Vault) LoadFromBytes(b []byte) error

LoadFromBytes loads vault data from an array of bytes.

func (*Vault) LoadFromFile

func (v *Vault) LoadFromFile(fp string) error

LoadFromFile loads vault data from a file.

func (*Vault) LoadPasswordFromFile

func (v *Vault) LoadPasswordFromFile(fp string) error

LoadPasswordFromFile loads unlock password for the vault from a file.

func (*Vault) SetPassword

func (v *Vault) SetPassword(s string) error

SetPassword sets unlock password for the vault.

type VaultBody

type VaultBody struct {
	Salt []byte `xml:"-" json:"-" yaml:"-"`
	HMAC []byte `xml:"-" json:"-" yaml:"-"`
	Data []byte `xml:"-" json:"-" yaml:"-"`
}

VaultBody is the body of a Vault.

type VaultCredential

type VaultCredential struct {
	Description     string `xml:"description,omitempty" json:"description,omitempty" yaml:"description,omitempty"`
	Regex           string `xml:"regex,omitempty" json:"regex,omitempty" yaml:"regex,omitempty"`
	Username        string `xml:"username,omitempty" json:"username,omitempty" yaml:"username,omitempty"`
	Password        string `xml:"password,omitempty" json:"password,omitempty" yaml:"password,omitempty"`
	EnabledPassword string `xml:"password_enable,omitempty" json:"password_enable,omitempty" yaml:"password_enable,omitempty"`
	Priority        int    `xml:"priority,omitempty" json:"priority,omitempty" yaml:"priority,omitempty"`
	Default         bool   `xml:"default,omitempty" json:"default,omitempty" yaml:"default,omitempty"`
}

VaultCredential is a decoded credential from a Vault.

func (*VaultCredential) String

func (c *VaultCredential) String() string

type VaultHeader

type VaultHeader struct {
	Format  string `xml:"-" json:"-" yaml:"-"`
	Version string `xml:"-" json:"-" yaml:"-"`
	Cipher  string `xml:"-" json:"-" yaml:"-"`
}

VaultHeader is the header of a Vault.

type VaultKey

type VaultKey struct {
	Cipher               []byte `xml:"-" json:"-" yaml:"-"`
	HMAC                 []byte `xml:"-" json:"-" yaml:"-"`
	InitializationVector []byte `xml:"-" json:"-" yaml:"-"`
}

VaultKey is the key for a Vault

Jump to

Keyboard shortcuts

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