ansible

package
v0.0.0-...-3513a05 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitEmbeddedModules

func InitEmbeddedModules()

func ModuleGetCache

func ModuleGetCache(typ, name string) *fast.Interp

func ModuleIsFact

func ModuleIsFact(name string) bool

func ModuleIsTask

func ModuleIsTask(name string) bool

Checks if the module is available

func ModuleSetCache

func ModuleSetCache(typ, name string, interp *fast.Interp)

func ModulesList

func ModulesList(typ string) (out []string)

Lists the modules of specified type

func TaskV1FieldInfo

func TaskV1FieldInfo(field *reflect.StructField) (info fieldInfo, err error)

Get information from the TaskV1 field tags, useful when processing semi-automatically

func TaskV1SetData

func TaskV1SetData(task_ptr any, fmap OrderedMap) error

To set data into the typical task struct according to defined field tags

func ToYaml

func ToYaml(obj any) (string, error)

Allows to convert any object to good Yaml string

Types

type OrderedMap

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

func CollectV1

func CollectV1(name string) (out *OrderedMap, err error)

func TaskV1GetData

func TaskV1GetData(task_ptr any) (fmap OrderedMap)

To get data from a typical task struct according to defined field tags It returns list of key-value pairs to preserve the order of fields

func (*OrderedMap) Data

func (om *OrderedMap) Data() map[string]any

func (*OrderedMap) Get

func (om *OrderedMap) Get(key string) (any, bool)

func (*OrderedMap) Keys

func (om *OrderedMap) Keys() (keys []string)

func (*OrderedMap) MarshalYAML

func (om *OrderedMap) MarshalYAML() (interface{}, error)

func (*OrderedMap) Pop

func (om *OrderedMap) Pop(key string) (v any, ok bool)

func (*OrderedMap) Set

func (om *OrderedMap) Set(key string, value any)

func (*OrderedMap) Size

func (om *OrderedMap) Size() int

func (*OrderedMap) UnmarshalYAML

func (om *OrderedMap) UnmarshalYAML(node *yaml.Node) error

func (*OrderedMap) Yaml

func (om *OrderedMap) Yaml() (string, error)

type P_TaskV1Interface

type P_TaskV1Interface struct {
	Object   any
	GetData_ func(_obj_ any) OrderedMap
	Run_     func(_obj_ any, vars map[string]any) (OrderedMap, error)
	SetData_ func(_obj_ any, data *OrderedMap) error
}

Proxy is needed for interface conversion from script to be compiled WARNING: the order of func fields in proxy is ABC: https://github.com/cosmos72/gomacro/issues/128

func (*P_TaskV1Interface) GetData

func (P *P_TaskV1Interface) GetData() OrderedMap

func (*P_TaskV1Interface) Run

func (P *P_TaskV1Interface) Run(vars map[string]any) (OrderedMap, error)

func (*P_TaskV1Interface) SetData

func (P *P_TaskV1Interface) SetData(data *OrderedMap) error

type Playbook

type Playbook struct {
	Name         string      `yaml:",omitempty"`
	Gather_facts bool        `default:"true" yaml:",omitempty"`
	Environment  *OrderedMap `yaml:",omitempty"`

	Pre_tasks []*Task `yaml:",omitempty"`

	Tasks []*Task `yaml:",omitempty"`

	Roles []*Role `yaml:",omitempty"`

	Post_tasks []*Task `yaml:",omitempty"`
}

func (*Playbook) Run

func (p *Playbook) Run(cfg *core.PlaybookConfig, host *inventory.Host) (err error)

func (*Playbook) UnmarshalYAML

func (p *Playbook) UnmarshalYAML(unmarshal func(interface{}) error) error

Allows to set defaults from struct definition

func (*Playbook) Yaml

func (p *Playbook) Yaml() (string, error)

type PlaybookFile

type PlaybookFile []Playbook

func (*PlaybookFile) Load

func (pf *PlaybookFile) Load(yml_path string) error

func (*PlaybookFile) Parse

func (pf *PlaybookFile) Parse(data []byte) error

func (*PlaybookFile) Yaml

func (pf *PlaybookFile) Yaml() (string, error)

type Role

type Role struct {
	Name        string      `yaml:"role"`
	Environment *OrderedMap `yaml:",omitempty"`
	Vars        *OrderedMap `yaml:",omitempty"`
}

func (*Role) Load

func (r *Role) Load(yml_path string) error

func (*Role) Parse

func (r *Role) Parse(data []byte) error

func (*Role) Run

func (r *Role) Run(vars map[string]any) (OrderedMap, error)

func (*Role) Yaml

func (r *Role) Yaml() (string, error)

type TAny

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

func (*TAny) IsEmpty

func (t *TAny) IsEmpty() bool

func (*TAny) MarshalYAML

func (t *TAny) MarshalYAML() (any, error)

func (*TAny) SetMeta

func (t *TAny) SetMeta(mt fieldInfo)

func (*TAny) SetTemplate

func (t *TAny) SetTemplate(tmpl string)

func (*TAny) SetUnknown

func (t *TAny) SetUnknown(val any)

func (TAny) String

func (t TAny) String() string

func (*TAny) UnmarshalYAML

func (t *TAny) UnmarshalYAML(val *yaml.Node) error

func (*TAny) Validate

func (t *TAny) Validate() error

Use metadata to verify the stored value

type TAnyList

type TAnyList []TAny

type TAnyMap

type TAnyMap map[TString]TAny

type TBool

type TBool struct {
	TAny
}

func NewTBool

func NewTBool(val bool) (out TBool)

func (*TBool) SetValue

func (t *TBool) SetValue(val bool)

func (*TBool) Val

func (t *TBool) Val() bool

type TBoolList

type TBoolList []TBool

type TBoolMap

type TBoolMap map[TString]TBool

type TInt

type TInt struct {
	TAny
}

func NewTInt

func NewTInt(val int) (out TInt)

func (*TInt) SetValue

func (t *TInt) SetValue(val int)

func (*TInt) Val

func (t *TInt) Val() int

type TIntList

type TIntList []TInt

type TIntMap

type TIntMap map[TString]TInt

type TString

type TString struct {
	TAny
}

func NewTString

func NewTString(val string) (out TString)

func (*TString) SetValue

func (t *TString) SetValue(val string)

func (*TString) Val

func (t *TString) Val() string

type TStringList

type TStringList []TString

func (*TStringList) Val

func (t *TStringList) Val() (out []string)

type TStringMap

type TStringMap map[TString]TString

type Task

type Task struct {
	// Identifier. Can be used for documentation, in or tasks/handlers.
	Name TString `yaml:",omitempty"`
	// A dictionary that gets converted into environment vars to be provided for the task upon execution. This cannot affect Ansible itself nor its configuration, it just sets the variables for the code responsible for executing the task.
	Environment *TStringMap `yaml:",omitempty"`

	// Conditional expression, determines if an iteration of a task is run or not.
	When TString `yaml:",omitempty"` // Only string right now, array looks confusing
	// Boolean that controls if privilege escalation is used or not on Task execution.
	Become TBool `yaml:",omitempty"`
	// Dictionary/map of variables specified in task
	Vars *TAnyMap `yaml:",omitempty"`
	// Name of variable that will contain task status and module return data.
	Register TString `yaml:",omitempty"`

	// Host to execute task instead of the target (inventory_hostname). Connection vars from the delegated host will also be used for the task.
	Delegate_to TString `yaml:",omitempty"`
	// Conditional expression that overrides the task’s normal ‘failed’ status.
	Failed_when TString `yaml:",omitempty"`

	// Loop through list of items
	With_items TStringList `yaml:",omitempty"`
	// Loop through dict key value
	With_dict *TAnyMap `yaml:",omitempty"`

	// TODO: Actually block could be potentally a task module, but for now in v1 it's just a
	// special case of task. Maybe in v2 it will be possible to pass yaml nodes to the tasks to
	// properly process subtasks of block, who knows...
	Block []*Task `yaml:",omitempty"` // Special case, contains list of tasks to execute

	// Found task module name
	ModuleName string `yaml:"-"`
	// Loaded implementation of the task module
	ModuleData TaskV1Interface `yaml:"-"`
}

func (*Task) IsRemote

func (t *Task) IsRemote(vars map[string]any) bool

func (*Task) Load

func (t *Task) Load(yml_path string) error

func (*Task) MarshalYAML

func (t *Task) MarshalYAML() (any, error)

func (*Task) Parse

func (t *Task) Parse(data []byte) error

func (*Task) Run

func (t *Task) Run(vars map[string]any) (data OrderedMap, err error)

func (*Task) UnmarshalYAML

func (t *Task) UnmarshalYAML(value *yaml.Node) (err error)

Determine what kind of the additional fields is here The function checks every key in yaml map and compare it to the available in structure. The unknown fields are checking on available task and if task found - it's good, if not - then keep search until it found.

func (*Task) Yaml

func (t *Task) Yaml() (string, error)

type TaskV1Default

type TaskV1Default struct {
	Args OrderedMap // Various arguments for the particular task
}

TaskDefault is needed to represent a non-implemented task

func (*TaskV1Default) GetData

func (t *TaskV1Default) GetData() OrderedMap

func (*TaskV1Default) Run

func (t *TaskV1Default) Run(vars map[string]any) error

func (*TaskV1Default) SetData

func (t *TaskV1Default) SetData(data *OrderedMap) error

type TaskV1Interface

type TaskV1Interface interface {
	Run(vars map[string]any) (OrderedMap, error)
	SetData(data *OrderedMap) error
	GetData() OrderedMap
}

func GetTaskV1

func GetTaskV1(name string) (out TaskV1Interface, err error)

Directories

Path Synopsis
fact
apt
uri

Jump to

Keyboard shortcuts

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