ansible

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// AnsibleHostPodAnnotationPrefix is the annotation prefix used on the RC to associate a host name with a pod name
	AnsibleHostPodAnnotationPrefix = "pod.kansible.fabric8.io/"

	// HostInventoryAnnotation is the list of hosts from the inventory
	HostInventoryAnnotation = "kansible.fabric8.io/host-inventory"

	// HostNameAnnotation is used to annotate a pod with the host name its processing
	HostNameAnnotation = "kansible.fabric8.io/host-name"

	// HostAddressAnnotation is used to annotate a pod with the host address its processing
	HostAddressAnnotation = "kansible.fabric8.io/host-address"

	// WinRMShellAnnotationPrefix stores the shell ID for the WinRM host name on the RC
	WinRMShellAnnotationPrefix = "winrm.shellid.kansible.fabric8.io/"

	// EnvHosts is the environment variable on a pod for specifying the Ansible hosts in the inventory
	EnvHosts = "KANSIBLE_HOSTS"

	// EnvCommand is the environment variable on a pod for specifying the command to run on each host
	EnvCommand = "KANSIBLE_COMMAND"

	// EnvRC is the environment variable on a pod for the name of the ReplicationController
	EnvRC = "KANSIBLE_RC"

	// EnvNamespace is the environment variable on a pod for the namespace to use
	EnvNamespace = "KANSIBLE_NAMESPACE"

	// EnvExportEnvVars is the space separated list of environment variables exported to the remote process
	EnvExportEnvVars = "KANSIBLE_EXPORT_ENV_VARS"

	// EnvPortForward allows port forwarding to be disabled
	EnvPortForward = "KANSIBLE_PORT_FORWARD"

	// EnvBash is the environment variable on a pod for the name of the bash script to generate on startup for
	// opening a remote shell
	EnvBash = "KANSIBLE_BASH"

	// EnvIsBashShell is used to indicate of the command running remotely on the machine is a bash shell in which case we
	// don't want to delete any previous WinRM shell
	EnvIsBashShell = "KANSIBLE_IS_BASH_SHELL"

	// PlaybookVolumeMount is the volume mount point where the playbook is assumed to be in the supervisor pod
	PlaybookVolumeMount = "/playbook"

	// AnsibleVariableHost is the Ansible inventory host variable for the remote host
	AnsibleVariableHost = "ansible_host"

	// AnsibleVariableUser is the Ansible inventory host variable for the remote user
	AnsibleVariableUser = "ansible_user"

	// AnsibleVariablePort is the Ansible inventory host variable for the reote port
	AnsibleVariablePort = "ansible_port"

	// AnsibleVariablePrivateKey is the Ansible inventory host variable for the SSH private key file
	AnsibleVariablePrivateKey = "ansible_ssh_private_key_file"

	// AnsibleVariableConnection is the Ansible inventory host variable for the kind of connection; e.g. 'winrm' for windows
	AnsibleVariableConnection = "ansible_connection"

	// AnsibleVariablePassword is the Ansible inventory host variable for the password
	AnsibleVariablePassword = "ansible_ssh_pass"

	// ConnectionWinRM is the value AnsibleVariableConnection of for using Windows with WinRM
	ConnectionWinRM = "winrm"

	// AppRunCommand is the Ansible inventory host variable for the run command that is executed on the remote host
	AppRunCommand = "app_run_command"
)
View Source
const (
	// AnsibleGlobalVariablesFile is the prefix file name for the Ansible global variables file
	AnsibleGlobalVariablesFile = "group_vars/"
)

Variables

This section is empty.

Functions

func HostEntriesToString

func HostEntriesToString(hostEntries []*HostEntry) string

HostEntriesToString generates the Ansible inventory text for the host entries

func LoadAnsibleVariables

func LoadAnsibleVariables(hosts string) (map[string]string, error)

LoadAnsibleVariables loads the global variables from the Ansible playbook so that we can search and replace them inside other files like the RC.yml

func LoadFileAndReplaceVariables

func LoadFileAndReplaceVariables(filename string, variables map[string]string) ([]byte, error)

LoadFileAndReplaceVariables loads the given file and replaces all the Ansible variable expressions and then returns the data

func ReplaceVariables

func ReplaceVariables(text string, variables map[string]string) string

ReplaceVariables replaces variables in the given string using the Ansible variable syntax of `{{ name }}`

func UpdateKansibleRC

func UpdateKansibleRC(hostEntries []*HostEntry, hosts string, f *cmdutil.Factory, c *client.Client, ns string, rcFile string, replicas int) (*api.ReplicationController, error)

UpdateKansibleRC reads the Ansible inventory and the RC YAML for the hosts and updates it in Kubernetes along with removing any remaining pods which are running against old hosts that have been removed from the inventory

Types

type HostEntry

type HostEntry struct {
	Name       string
	Host       string
	Port       string
	User       string
	PrivateKey string
	Connection string
	Password   string
	RunCommand string
}

HostEntry represents a single host entry in an Ansible inventory

func ChooseHostAndPrivateKey

func ChooseHostAndPrivateKey(thisPodName string, hosts string, c *client.Client, ns string, rcName string) (*HostEntry, *api.ReplicationController, map[string]string, error)

ChooseHostAndPrivateKey parses the given Ansible inventory file for the hosts and chooses a single host inside it, returning the host name and the private key

func GetHostEntryByName

func GetHostEntryByName(hostEntries []*HostEntry, name string) *HostEntry

GetHostEntryByName finds the HostEntry for the given host name or returns nil

func LoadHostEntries

func LoadHostEntries(inventoryFile string, hosts string) ([]*HostEntry, error)

LoadHostEntries loads the Ansible inventory for a given hosts string value

func LoadHostEntriesFromText

func LoadHostEntriesFromText(text string) ([]*HostEntry, error)

LoadHostEntriesFromText loads the host entries from the given text which is typically taken from an annotation on the ReplicationController

Jump to

Keyboard shortcuts

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