db

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 14 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
	GroupsRef map[string]bool
	Hosts     []*InventoryHost
	Groups    []*InventoryGroup
}

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) 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(s 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
	Ancestors []string
	Variables map[string]string
	Counters  struct {
		Hosts  uint64
		Groups uint64
	}
}

InventoryGroup is an group of InventoryHost instances.

type InventoryHost

type InventoryHost struct {
	Name        string
	Parent      string
	Variables   map[string]string
	Groups      []string
	GroupChains []string
}

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" json:"description" yaml:"description"`
	Regex           string `xml:"regex" json:"regex" yaml:"regex"`
	Username        string `xml:"username" json:"username" yaml:"username"`
	Password        string `xml:"password" json:"password" yaml:"password"`
	EnabledPassword string `xml:"password_enable" json:"password_enable" yaml:"password_enable"`
	Priority        int    `xml:"priority" json:"priority" yaml:"priority"`
	Default         bool   `xml:"default" json:"default" yaml:"default"`
}

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