ansible

package
v0.3.10-0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 15 Imported by: 19

Documentation

Index

Constants

View Source
const (
	PUBLIC_CLOUD_ANSIBLE_USER = "cloudroot"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Host

type Host struct {
	// Name denotes the host to operate on
	Name string
	// Vars is a map recording host vars
	Vars map[string]string
}

Host represents an ansible host

func ParseHostLine

func ParseHostLine(s string) (host Host, err error)

ParseHostLine parse string representation of an ansible host

Input should be in format "name key=value"

func (*Host) GetVar

func (h *Host) GetVar(k string) (v string, exist bool)

GetVar returns variable value. Second return value will be false if the variable does not exist

func (*Host) SetVar

func (h *Host) SetVar(k, v string)

SetVar sets variable k to value v

type Inventory

type Inventory struct {
	Hosts []Host
}

Inventory contains a list of ansible hosts

func (*Inventory) Data

func (i *Inventory) Data() []byte

Data returns serialized form of the inventory as represented on disk

func (*Inventory) IsEmpty

func (i *Inventory) IsEmpty() bool

IsEmpty returns true if the inventory is empty

type Module

type Module struct {
	// Name is ansible module name
	Name string
	// Args is a list of module arguments in form of key=value
	Args []string
}

Module represents name and args of ansible module to execute

func ParseModuleLine

func ParseModuleLine(s string) (mod Module, err error)

ParseModuleLine parse string representation of an ansible module task

The input should be in format "name key=value arg0 arg1". The argN form is For module "command" and "shell"

type Playbook

type Playbook struct {
	Inventory  Inventory
	Modules    []Module
	PrivateKey []byte
	Files      map[string][]byte
	// contains filtered or unexported fields
}

func NewPlaybook

func NewPlaybook() *Playbook

func (*Playbook) CleanOnExit

func (pb *Playbook) CleanOnExit(b bool)

CleanOnExit decide whether temporary workdir will be cleaned up after Run

func (*Playbook) Copy

func (pb *Playbook) Copy() *Playbook

func (*Playbook) IsZero

func (pb *Playbook) IsZero() bool

IsZero implements gotypes.ISerializable

func (*Playbook) OutputWriter

func (pb *Playbook) OutputWriter(w io.Writer)

func (*Playbook) Run

func (pb *Playbook) Run(ctx context.Context) (err error)

Run runs the playbook

func (*Playbook) Runnable

func (pb *Playbook) Runnable() bool

Runnable returns whether the playbook is in a state feasible to be run

func (*Playbook) Running

func (pb *Playbook) Running() bool

Running returns whether the playbook is currently running

func (*Playbook) State

func (pb *Playbook) State() pbState

State returns current state of the playbook

func (*Playbook) String

func (pb *Playbook) String() string

String implements gotypes.ISerializable

type Runnable

type Runnable interface {
	Run(context.Context) error
}

type Session

type Session struct {
	// Ctx is the context under which the playbook will run
	Ctx context.Context
	// Runnable is the task to be run
	Runnable Runnable
	// contains filtered or unexported fields
}

Session is a container for execution of playbook

type SessionManager

type SessionManager map[string]*Session

SessionManager manages a collection of keyed sessions

func (SessionManager) Add

func (sm SessionManager) Add(id string, runnable Runnable) *Session

Add adds a Runnable to the manager keyed with the specified id

func (SessionManager) Err

func (sm SessionManager) Err(id string) error

Err returns possible error from sm.Ctx.Err()

func (SessionManager) Has

func (sm SessionManager) Has(id string) bool

Has returns true if a session with the specified id exists in the manager

func (SessionManager) Remove

func (sm SessionManager) Remove(id string)

Remove stops (if appliable) and removes the playbook keyed with the specified id from the manager

func (SessionManager) Run

func (sm SessionManager) Run(id string) error

Run runs the playbook keyed with specified id

func (SessionManager) Stop

func (sm SessionManager) Stop(id string)

Stop stops the playbook keyed with specified id

Jump to

Keyboard shortcuts

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