ansible

package
v0.0.0-...-4a20579 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PlaybookCmd is a command for executing ansible playbooks.
	PlaybookCmd = "ansible-playbook"
)

Variables

This section is empty.

Functions

func GetContrailVersion

func GetContrailVersion(cluster *models.ContrailCluster, logger *logrus.Entry) string

GetContrailVersion returns Contrail version specified by user.

func ImageReference

func ImageReference(registry, imageName, imageTag string) (string, error)

ImageReference returns image reference.

Types

type CLIClient

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

CLIClient allows to play Ansible playbooks via ansible-playbook CLI.

func NewCLIClient

func NewCLIClient(
	reporter *report.Reporter,
	logFilePath string,
	workingDirectory string,
	isTestInstance bool,
) *CLIClient

NewCLIClient returns CLIClient.

func (*CLIClient) IsTest

func (c *CLIClient) IsTest() bool

IsTest returns true for testing instance. TODO: move test logic to separate Mock type and use dependency injection using ansible.Player interface.

func (*CLIClient) Play

func (c *CLIClient) Play(repositoryPath string, ansibleArgs []string, virtualenvPath string) error

Play plays Ansible playbook via ansible-playbook CLI. It runs playbook from in give virtualenv directory if non-zero value virtualenvPath is given.

func (*CLIClient) Test

func (c *CLIClient) Test() bool

Test returns whether CLI Client belongs to test instance or not.

func (*CLIClient) WorkingDirectory

func (c *CLIClient) WorkingDirectory() string

WorkingDirectory returns working directory.

type ContainerParameters

type ContainerParameters struct {
	// HostVolumes is the list of volumes that will be mounted from host to container.
	// If ForceContainerRecreate is disabled and Container exists it won't load current volumes!
	HostVolumes []Volume
	// Env is a list of environment variables. Single string value should be in form KEY=VALUE.
	Env []string
	// ImageRef is the name of image that will be pulled for certain action REGISTRY/IMAGE_NAME:TAG.
	ImageRef string
	// ImageRefUsername is a username for Docker registry.
	ImageRefUsername string
	// ImageRefPassword is a password for Docker registry.
	ImageRefPassword string
	// WorkingDirectory is the directory from which a command is started.
	WorkingDirectory string
	// ContainerPrefix is the prefix that will be used for container name.
	ContainerPrefix string
	// If true instead of starting base container entrypoint it will call command to keep it alive.
	OverwriteEntrypoint bool
	// ForceContainerRecreate determines whether if there was an existing container should it be used or removed
	// and created again to use current volumes.
	ForceContainerRecreate bool
	// RemoveContainer determines whether container should be removed after its work.
	RemoveContainer bool
	// HostNetwork determines whether new container should have access to host's network configuration.
	HostNetwork bool
	// Privileged gives all capabilities to the container.
	Privileged bool
}

ContainerParameters holds all the necessary parameters for executing a command in container.

func (*ContainerParameters) String

func (c *ContainerParameters) String() string

type ContainerPlayer

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

ContainerPlayer plays Ansible playbooks via docker exec.

func NewContainerPlayer

func NewContainerPlayer(reporter *report.Reporter, logFilePath string) (*ContainerPlayer, error)

NewContainerPlayer returns *ContainerPlayer.

func (*ContainerPlayer) StartExecuteAndRemove

func (p *ContainerPlayer) StartExecuteAndRemove(
	ctx context.Context, cp *ContainerParameters, cmd []string,
) (err error)

StartExecuteAndRemove creates a container, executes certain command and after completion it removes that container. The first element of cmd is command and the rest are its parameters. Notice that imageRepo should already be added to docker daemon's insecure registry list by contrail-command-deployer, so private insecure registries don't need extra care when getting pulled.

type Volume

type Volume struct {
	Source string
	Target string
}

Volume represents a configuration for a Volume that will be added to Container.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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