ansible

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Overview

Package ansible contains libraries for interacting with the Ansible IT automation tool.

Index

Constants

View Source
const (
	// RawFormat is the raw Ansible output formatting
	RawFormat = OutputFormat("raw")
	// JSONLinesFormat is a JSON Lines representation of Ansible events
	JSONLinesFormat = OutputFormat("json_lines")
)

Variables

This section is empty.

Functions

func EventStream

func EventStream(in io.Reader) <-chan Event

EventStream reads JSON lines from the incoming stream, and convert them into a stream of events.

Types

type AdditionalFile added in v1.9.2

type AdditionalFile struct {
	Source      string
	Destination string
	Hosts       []string
}

type ClusterCatalog added in v1.2.0

type ClusterCatalog struct {
	Versions struct {
		Kubernetes    string `yaml:"kubernetes"`
		KubernetesYum string `yaml:"kubernetes_yum"`
		KubernetesDeb string `yaml:"kubernetes_deb"`
	}

	ClusterName               string `yaml:"kubernetes_cluster_name"`
	AdminPassword             string `yaml:"kubernetes_admin_password"`
	TLSDirectory              string `yaml:"tls_directory"`
	ServicesCIDR              string `yaml:"kubernetes_services_cidr"`
	PodCIDR                   string `yaml:"kubernetes_pods_cidr"`
	DNSServiceIP              string `yaml:"kubernetes_dns_service_ip"`
	EnableModifyHosts         bool   `yaml:"modify_hosts_file"`
	EnablePackageInstallation bool   `yaml:"allow_package_installation"`
	DisconnectedInstallation  bool   `yaml:"disconnected_installation"`
	KuberangPath              string `yaml:"kuberang_path"`
	LoadBalancer              string `yaml:"kubernetes_load_balancer"`
	LoadBalancerPort          string `yaml:"kubernetes_load_balancer_port"`

	APIServerOptions             map[string]string `yaml:"kubernetes_api_server_option_overrides"`
	KubeControllerManagerOptions map[string]string `yaml:"kube_controller_manager_option_overrides"`
	KubeSchedulerOptions         map[string]string `yaml:"kube_scheduler_option_overrides"`
	KubeProxyOptions             map[string]string `yaml:"kube_proxy_option_overrides"`
	KubeletOptions               map[string]string `yaml:"kubelet_overrides"`

	AdditionalFiles []AdditionalFile `yaml:"additional_files"`

	ConfigureDockerWithPrivateRegistry bool   `yaml:"configure_docker_with_private_registry"`
	DockerRegistryCAPath               string `yaml:"docker_certificates_ca_path"`
	DockerRegistryServer               string `yaml:"docker_registry_full_url"`
	DockerRegistryUsername             string `yaml:"docker_registry_username"`
	DockerRegistryPassword             string `yaml:"docker_registry_password"`

	ForceEtcdRestart              bool `yaml:"force_etcd_restart"`
	ForceAPIServerRestart         bool `yaml:"force_apiserver_restart"`
	ForceControllerManagerRestart bool `yaml:"force_controller_manager_restart"`
	ForceSchedulerRestart         bool `yaml:"force_scheduler_restart"`
	ForceProxyRestart             bool `yaml:"force_proxy_restart"`
	ForceKubeletRestart           bool `yaml:"force_kubelet_restart"`
	ForceCalicoNodeRestart        bool `yaml:"force_calico_node_restart"`
	ForceDockerRestart            bool `yaml:"force_docker_restart"`

	EnableConfigureIngress bool `yaml:"configure_ingress"`

	KismaticPreflightCheckerLinux string `yaml:"kismatic_preflight_checker"`

	NewNode string `yaml:"new_node"`

	NFSVolumes []NFSVolume `yaml:"nfs_volumes"`

	EnableGluster bool `yaml:"configure_storage"`

	// volume add vars
	VolumeName              string   `yaml:"volume_name"`
	VolumeReplicaCount      int      `yaml:"volume_replica_count"`
	VolumeDistributionCount int      `yaml:"volume_distribution_count"`
	VolumeStorageClass      string   `yaml:"volume_storage_class"`
	VolumeQuotaGB           int      `yaml:"volume_quota_gb"`
	VolumeQuotaBytes        int      `yaml:"volume_quota_bytes"`
	VolumeMount             string   `yaml:"volume_mount"`
	VolumeAllowedIPs        string   `yaml:"volume_allow_ips"`
	VolumeReclaimPolicy     string   `yaml:"volume_reclaim_policy"`
	VolumeAccessModes       []string `yaml:"volume_access_modes"`

	TargetVersion string `yaml:"kismatic_short_version"`

	OnlineUpgrade bool `yaml:"online_upgrade"`

	DiagnosticsDirectory string `yaml:"diagnostics_dir"`
	DiagnosticsDateTime  string `yaml:"diagnostics_date_time"`

	Docker struct {
		Enabled bool
		Logs    struct {
			Driver string            `yaml:"driver"`
			Opts   map[string]string `yaml:"opts"`
		}
		Storage struct {
			Driver               string               `yaml:"driver"`
			Opts                 map[string]string    `yaml:"opts"`
			OptsList             []string             `yaml:"opts_list"`
			DirectLVMBlockDevice DirectLVMBlockDevice `yaml:"direct_lvm_block_device"`
		}
	}

	LocalKubeconfigDirectory string `yaml:"local_kubeconfig_directory"`

	CloudProvider string `yaml:"cloud_provider"`
	CloudConfig   string `yaml:"cloud_config_local"`

	DNS struct {
		Enabled  bool
		Provider string
		Options  struct {
			Replicas int
		}
	}

	RunPodValidation bool `yaml:"run_pod_validation"`

	CNI struct {
		Enabled  bool
		Provider string
		Options  struct {
			Portmap struct {
				Enabled bool
			}
			Calico struct {
				Mode                  string
				LogLevel              string `yaml:"log_level"`
				WorkloadMTU           int    `yaml:"workload_mtu"`
				FelixInputMTU         int    `yaml:"felix_input_mtu"`
				IPAutodetectionMethod string `yaml:"ip_autodetection_method"`
			}
			Weave struct {
				Password string
			}
		}
	}

	Heapster struct {
		Enabled bool
		Options struct {
			Heapster struct {
				Replicas    int    `yaml:"replicas"`
				Sink        string `yaml:"sink"`
				ServiceType string `yaml:"service_type"`
			}
			InfluxDB struct {
				PVCName string `yaml:"pvc_name"`
			}
		}
	}

	MetricsServer struct {
		Enabled bool
	}

	Dashboard struct {
		Enabled bool
		Options struct {
			ServiceType string `yaml:"service_type"`
			NodePort    string `yaml:"node_port"`
		}
	}

	Helm struct {
		Enabled   bool
		Namespace string
	}

	Rescheduler struct {
		Enabled bool
	}

	InsecureNetworkingEtcd bool `yaml:"insecure_networking_etcd"`

	HTTPProxy  string `yaml:"http_proxy"`
	HTTPSProxy string `yaml:"https_proxy"`
	NoProxy    string `yaml:"no_proxy"`

	NodeLabels         map[string][]string          `yaml:"node_labels"`
	NodeTaints         map[string][]string          `yaml:"node_taints"`
	KubeletNodeOptions map[string]map[string]string `yaml:"kubelet_node_overrides"`
}

func (*ClusterCatalog) EnableRestart added in v1.2.0

func (c *ClusterCatalog) EnableRestart()

func (*ClusterCatalog) ToYAML added in v1.2.0

func (c *ClusterCatalog) ToYAML() ([]byte, error)

type DirectLVMBlockDevice added in v1.8.0

type DirectLVMBlockDevice struct {
	Path                        string
	ThinpoolPercent             string `yaml:"thinpool_percent"`
	ThinpoolMetaPercent         string `yaml:"thinpool_metapercent"`
	ThinpoolAutoextendThreshold string `yaml:"thinpool_autoextend_threshold"`
	ThinpoolAutoextendPercent   string `yaml:"thinpool_autoextend_percent"`
}

type Event

type Event interface {
	// Type is the name of the event type
	Type() string
}

Event produced by Ansible when running a playbook

type HandlerTaskStartEvent

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

HandlerTaskStartEvent signals the beginning of a handler task

func (*HandlerTaskStartEvent) Type

func (e *HandlerTaskStartEvent) Type() string

type Inventory

type Inventory struct {
	Roles []Role
}

Inventory is a collection of Nodes, keyed by role.

func (Inventory) ToINI

func (i Inventory) ToINI() []byte

ToINI converts the inventory into INI format

type NFSVolume added in v1.2.0

type NFSVolume struct {
	Host string
	Path string
}

type Node

type Node struct {
	// Host is the hostname of the target node
	Host string
	// PublicIP is the publicly accessible IP
	PublicIP string
	// InternalIP is the internal IP, if different from PublicIP.
	InternalIP string
	// SSHPrivateKey is the private key to be used for SSH authentication
	SSHPrivateKey string
	// SSHPort is the SSH port number for connecting to the node
	SSHPort int
	// SSHUser is the SSH user for logging into the node
	SSHUser string
}

Node is an Ansible target node

type OutputFormat

type OutputFormat string

OutputFormat is used for controlling the STDOUT format of the Ansible runner

type PlayStartEvent

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

PlayStartEvent signals the beginning of a play

func (*PlayStartEvent) Type

func (e *PlayStartEvent) Type() string

type PlaybookEndEvent

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

PlaybookEndEvent signals the beginning of a playbook

func (*PlaybookEndEvent) Type

func (e *PlaybookEndEvent) Type() string

type PlaybookStartEvent

type PlaybookStartEvent struct {
	Count int
	// contains filtered or unexported fields
}

PlaybookStartEvent signals the beginning of a playbook

func (*PlaybookStartEvent) Type

func (e *PlaybookStartEvent) Type() string

type Role

type Role struct {
	// Name of the role
	Name string
	// The nodes that belong to this role
	Nodes []Node
}

Role is an Ansible role, containing nodes that belong to the role.

type Runner

type Runner interface {
	// StartPlaybook runs the playbook asynchronously with the given inventory and extra vars.
	// It returns a read-only channel that must be consumed for the playbook execution to proceed.
	StartPlaybook(playbookFile string, inventory Inventory, cc ClusterCatalog) (<-chan Event, error)
	// WaitPlaybook blocks until the execution of the playbook is complete. If an error occurred,
	// it is returned. Otherwise, returns nil to signal the completion of the playbook.
	WaitPlaybook() error
	// StartPlaybookOnNode runs the playbook asynchronously with the given inventory and extra vars
	// against the specific node.
	// It returns a read-only channel that must be consumed for the playbook execution to proceed.
	StartPlaybookOnNode(playbookFile string, inventory Inventory, cc ClusterCatalog, node ...string) (<-chan Event, error)
}

Runner for running Ansible playbooks

func NewRunner

func NewRunner(out, errOut io.Writer, ansibleDir string, runDir string) (Runner, error)

NewRunner returns a new runner for running Ansible playbooks.

type RunnerFailedEvent

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

RunnerFailedEvent signals a failure when executing a runner

func (*RunnerFailedEvent) Type

func (e *RunnerFailedEvent) Type() string

type RunnerItemFailedEvent added in v1.1.1

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

RunnerItemFailedEvent signals the failure of a task with a specific item

func (*RunnerItemFailedEvent) Type added in v1.1.1

func (e *RunnerItemFailedEvent) Type() string

type RunnerItemOKEvent

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

RunnerItemOKEvent signals the successful completion of a runner item

func (*RunnerItemOKEvent) Type

func (e *RunnerItemOKEvent) Type() string

type RunnerItemRetryEvent

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

RunnerItemRetryEvent signals the retry of a runner item

func (*RunnerItemRetryEvent) Type

func (e *RunnerItemRetryEvent) Type() string

type RunnerOKEvent

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

RunnerOKEvent signals the successful completion of a runner

func (*RunnerOKEvent) Type

func (e *RunnerOKEvent) Type() string

type RunnerSkippedEvent

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

RunnerSkippedEvent is raised when a runner is skipped

func (*RunnerSkippedEvent) Type

func (e *RunnerSkippedEvent) Type() string

type RunnerUnreachableEvent

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

RunnerUnreachableEvent is raised when the target host is not reachable via SSH

func (*RunnerUnreachableEvent) Type

func (e *RunnerUnreachableEvent) Type() string

type TaskStartEvent

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

TaskStartEvent signals the beginning of a task

func (*TaskStartEvent) Type

func (e *TaskStartEvent) Type() string

Jump to

Keyboard shortcuts

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