inventory

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultAnsibleInventoryBinary is the default value for ansible binary file to run inventory modules
	DefaultAnsibleInventoryBinary = "ansible-inventory"

	// AskVaultPasswordFlag ask for vault password
	AskVaultPasswordFlag = "--ask-vault-password"

	// ExportFlag When doing an –list, represent in a way that is optimized for export, not as an accurate representation of how Ansible has processed it
	ExportFlag = "--export"

	// GraphFlag create inventory graph, if supplying pattern it must be a valid group name
	GraphFlag = "--graph"

	// HostFlag Output specific host info, works as inventory script
	HostFlag = "--host"

	// InventoryFlag is the inventory flag for ansible-inventory
	InventoryFlag = "--inventory"

	// LimitFlag further limit selected hosts to an additional pattern
	LimitFlag = "--limit"

	// ListFlag Output all hosts info, works as inventory script
	ListFlag = "--list"

	// OutputFlag When doing –list, send the inventory to a file instead of to the screen
	OutputFlag = "--output"

	// PlaybookDirFlag Since this tool does not use playbooks, use this as a substitute inventory directory. This sets the relative path for many features including roles/ group_vars/ etc.
	PlaybookDirFlag = "--playbook-dir"

	// TomlFlag Use TOML format instead of default JSON, ignored for –graph
	TomlFlag = "--toml"

	// VarsFlag Add vars to graph display, ignored unless used with –graph
	VarsFlag = "--vars"

	// ValutIdFlag the vault identity to use
	VaultIdFlag = "--vault-id"

	// ValutPasswordFileFlag vault password file
	VaultPasswordFileFlag = "--vault-password-file"

	// VerboseFlag verbose with -vvvv is enabled
	VerboseFlag = "-vvvv"

	// VerboseVFlag verbose with -v is enabled
	VerboseVFlag = "-v"

	// VerboseVVFlag verbose with -vv is enabled
	VerboseVVFlag = "-vv"

	// VerboseVVVFlag verbose with -vvv is enabled
	VerboseVVVFlag = "-vvv"

	// VerboseVVVVFlag verbose with -vvvv is enabled
	VerboseVVVVFlag = "-vvvv"

	// VersionFlag show program’s version number, config file location, configured module search path, module location, executable location and exit
	VersionFlag = "--version"

	// YamlFlag Use YAML format instead of default JSON, ignored for –graph
	YamlFlag = "--yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AnsibleInventoryCmd

type AnsibleInventoryCmd struct {
	// Ansible-inventory binary file
	Binary string
	// Pattern is the ansible's host or group pattern
	Pattern string
	// Options are the ansible's inventory options
	InventoryOptions *AnsibleInventoryOptions
}

AnsibleInventoryCmd object is the main object which defines the `ansible-inventory` inventory command and how to execute it.

func NewAnsibleInventoryCmd

func NewAnsibleInventoryCmd(options ...AnsibleInventoryOptionFunc) *AnsibleInventoryCmd

NewAnsibleInventoryCmd creates a new AnsibleInventoryCmd instance

func (*AnsibleInventoryCmd) Command

func (p *AnsibleInventoryCmd) Command() ([]string, error)

Command generate the ansible command which will be executed

func (*AnsibleInventoryCmd) String

func (p *AnsibleInventoryCmd) String() string

String returns AnsibleInventoryCmd as string

type AnsibleInventoryExecute

type AnsibleInventoryExecute struct {
	// contains filtered or unexported fields
}

AnsibleInventoryExecute is an executor for ansible-inventory command that runs the command using a DefaultExecute with default options

func NewAnsibleInventoryExecute

func NewAnsibleInventoryExecute() *AnsibleInventoryExecute

NewAnsibleInventoryExecute returns a new AnsibleInventoryExecute. It receives a pattern to be used to filter the inventory

func (*AnsibleInventoryExecute) Execute

func (e *AnsibleInventoryExecute) Execute(ctx context.Context) error

Execute method runs the ansible-inventory command using a DefaultExecute with default options

func (*AnsibleInventoryExecute) WithBinary

WithBinary return a AnsibleInventoryExecute withthe binary file set

func (*AnsibleInventoryExecute) WithInventoryOptions

func (e *AnsibleInventoryExecute) WithInventoryOptions(options *AnsibleInventoryOptions) *AnsibleInventoryExecute

WithInventoryOptions returns an AnsibleInventoryExecute with the ansible's inventory options set

func (*AnsibleInventoryExecute) WithPattern

func (e *AnsibleInventoryExecute) WithPattern(pattern string) *AnsibleInventoryExecute

WithPattern return a AnsibleInventoryExecute withthe binary file set

type AnsibleInventoryOptionFunc

type AnsibleInventoryOptionFunc func(*AnsibleInventoryCmd)

AnsibleInventoryOptionFunc is a function to set executor options

func WithBinary

func WithBinary(binary string) AnsibleInventoryOptionFunc

WithBinary set the ansible-inventory binary file

func WithInventoryOptions

func WithInventoryOptions(options *AnsibleInventoryOptions) AnsibleInventoryOptionFunc

WithInventoryOptions set the ansible-inventory options

func WithPattern

func WithPattern(pattern string) AnsibleInventoryOptionFunc

WithPattern set the adhoc pattern

type AnsibleInventoryOptions

type AnsibleInventoryOptions struct {
	// AskVaultPassword ask for vault password
	AskVaultPassword bool

	// Export When doing an –list, represent in a way that is optimized for export,not as an accurate representation of how Ansible has processed it
	Export bool

	// Graph create inventory graph, if supplying pattern it must be a valid group name
	Graph bool

	// Host Output specific host info, works as inventory script
	Host string

	// Inventory is the inventory flag for ansible-inventory
	Inventory string

	// Limit further limit selected hosts to an additional pattern
	Limit string

	// List Output all hosts info, works as inventory script
	List bool

	// Output When doing –list, send the inventory to a file instead of to the screen
	Output string

	// PlaybookDir Since this tool does not use playbooks, use this as a substitute inventory directory.This sets the relative path for many features including roles/ group_vars/ etc.
	PlaybookDir string

	// Toml Use TOML format instead of default JSON, ignored for –graph
	Toml bool

	// Vars Add vars to graph display, ignored unless used with –graph
	Vars bool

	// VaultID the vault identity to use
	VaultID string

	// VaultPasswordFile vault password file
	VaultPasswordFile string

	// Verbose verbose mode enabled
	Verbose bool

	// VerboseV verbose with -v is enabled
	VerboseV bool

	// VerboseVV verbose with -vv is enabled
	VerboseVV bool

	// VerboseVVV verbose with -vvv is enabled
	VerboseVVV bool

	// VerboseVVVV verbose with -vvvv is enabled
	VerboseVVVV bool

	// Version show program’s version number, config file location, configured module search path, module location, executable location and exit
	Version bool

	// Yaml Use YAML format instead of default JSON, ignored for –graph
	Yaml bool
}

AnsibleInventoryOptions object has those parameters described on `Options` section within ansible-inventory's man page, and which defines which should be the ansible-inventory execution behavior.

func (*AnsibleInventoryOptions) GenerateCommandOptions

func (o *AnsibleInventoryOptions) GenerateCommandOptions() ([]string, error)

GenerateCommandOptions return a list of command options flags to be used on ansible execution

func (*AnsibleInventoryOptions) String

func (o *AnsibleInventoryOptions) String() string

GenerateCommandCommonOptions return a list of command options flags to be used on ansible execution

Jump to

Keyboard shortcuts

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