ansiblelocal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MPL-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultStagingDir = "/tmp/packer-provisioner-ansible-local"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	common.PackerConfig `mapstructure:",squash"`

	// The command to invoke ansible. Defaults to
	//  `ansible-playbook`. If you would like to provide a more complex command,
	//  for example, something that sets up a virtual environment before calling
	//  ansible, take a look at the ansible wrapper guide below for inspiration.
	//  Please note that Packer expects Command to be a path to an executable.
	//  Arbitrary bash scripting will not work and needs to go inside an
	//  executable script.
	Command string `mapstructure:"command"`
	// Extra arguments to pass to Ansible.
	// These arguments _will not_ be passed through a shell and arguments should
	// not be quoted. Usage example:
	//
	// “`json
	//   "extra_arguments": [ "--extra-vars", "Region={{user `Region`}} Stage={{user `Stage`}}" ]
	// “`
	// In certain scenarios where you want to pass ansible command line arguments
	// that include parameter and value (for example `--vault-password-file pwfile`),
	// from ansible documentation this is correct format but that is NOT accepted here.
	// Instead you need to do it like `--vault-password-file=pwfile`.
	//
	// If you are running a Windows build on AWS, Azure, Google Compute, or OpenStack
	// and would like to access the auto-generated password that Packer uses to
	// connect to a Windows instance via WinRM, you can use the template variable
	// `{{.WinRMPassword}}` in this option. For example:
	//
	// “`json
	//   "extra_arguments": [
	//     "--extra-vars", "winrm_password={{ .WinRMPassword }}"
	//   ]
	// “`
	ExtraArguments []string `mapstructure:"extra_arguments"`
	// A path to the directory containing ansible group
	// variables on your local system to be copied to the remote machine. By
	// default, this is empty.
	GroupVars string `mapstructure:"group_vars"`
	// A path to the directory containing ansible host variables on your local
	// system to be copied to the remote machine. By default, this is empty.
	HostVars string `mapstructure:"host_vars"`
	// A path to the complete ansible directory structure on your local system
	// to be copied to the remote machine as the `staging_directory` before all
	// other files and directories.
	PlaybookDir string `mapstructure:"playbook_dir"`
	// The playbook file to be executed by ansible. This file must exist on your
	// local system and will be uploaded to the remote machine. This option is
	// exclusive with `playbook_files`.
	PlaybookFile string `mapstructure:"playbook_file"`
	// The playbook files to be executed by ansible. These files must exist on
	// your local system. If the files don't exist in the `playbook_dir` or you
	// don't set `playbook_dir` they will be uploaded to the remote machine. This
	// option is exclusive with `playbook_file`.
	PlaybookFiles []string `mapstructure:"playbook_files"`
	// An array of directories of playbook files on your local system. These
	// will be uploaded to the remote machine under `staging_directory`/playbooks.
	// By default, this is empty.
	PlaybookPaths []string `mapstructure:"playbook_paths"`
	// An array of paths to role directories on your local system. These will be
	// uploaded to the remote machine under `staging_directory`/roles. By default,
	// this is empty.
	RolePaths []string `mapstructure:"role_paths"`
	// The directory where all the configuration of Ansible by Packer will be placed.
	// By default this is `/tmp/packer-provisioner-ansible-local/<uuid>`, where
	// `<uuid>` is replaced with a unique ID so that this provisioner can be run more
	// than once. If you'd like to know the location of the staging directory in
	// advance, you should set this to a known location. This directory doesn't need
	// to exist but must have proper permissions so that the SSH user that Packer uses
	// is able to create directories and write into this folder. If the permissions
	// are not correct, use a shell provisioner prior to this to configure it
	// properly.
	StagingDir string `mapstructure:"staging_directory"`
	// If set to `true`, the content of the `staging_directory` will be removed after
	// executing ansible. By default this is set to `false`.
	CleanStagingDir bool `mapstructure:"clean_staging_directory"`
	// The inventory file to be used by ansible. This
	// file must exist on your local system and will be uploaded to the remote
	// machine.
	//
	// When using an inventory file, it's also required to `--limit` the hosts to the
	// specified host you're building. The `--limit` argument can be provided in the
	// `extra_arguments` option.
	//
	// An example inventory file may look like:
	//
	// “`text
	// [chi-dbservers]
	// db-01 ansible_connection=local
	// db-02 ansible_connection=local
	//
	// [chi-appservers]
	// app-01 ansible_connection=local
	// app-02 ansible_connection=local
	//
	// [chi:children]
	// chi-dbservers
	// chi-appservers
	//
	// [dbservers:children]
	// chi-dbservers
	//
	// [appservers:children]
	// chi-appservers
	// “`
	InventoryFile string `mapstructure:"inventory_file"`
	// `inventory_groups` (string) - A comma-separated list of groups to which
	// packer will assign the host `127.0.0.1`. A value of `my_group_1,my_group_2`
	// will generate an Ansible inventory like:
	//
	// “`text
	// [my_group_1]
	// 127.0.0.1
	// [my_group_2]
	// 127.0.0.1
	// “`
	InventoryGroups []string `mapstructure:"inventory_groups"`
	// A requirements file which provides a way to
	//  install roles or collections with the [ansible-galaxy
	//  cli](https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#the-ansible-galaxy-command-line-tool)
	//  on the local machine before executing `ansible-playbook`. By default, this is empty.
	GalaxyFile string `mapstructure:"galaxy_file"`
	// The command to invoke ansible-galaxy. By default, this is
	// `ansible-galaxy`.
	GalaxyCommand string `mapstructure:"galaxy_command"`
	// contains filtered or unexported fields
}

func (*Config) FlatMapstructure

func (*Config) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatConfig. FlatConfig is an auto-generated flat version of Config. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

type FlatConfig

type FlatConfig struct {
	PackerBuildName     *string           `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"`
	PackerBuilderType   *string           `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"`
	PackerCoreVersion   *string           `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"`
	PackerDebug         *bool             `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"`
	PackerForce         *bool             `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"`
	PackerOnError       *string           `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
	PackerUserVars      map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
	PackerSensitiveVars []string          `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
	Command             *string           `mapstructure:"command" cty:"command" hcl:"command"`
	ExtraArguments      []string          `mapstructure:"extra_arguments" cty:"extra_arguments" hcl:"extra_arguments"`
	GroupVars           *string           `mapstructure:"group_vars" cty:"group_vars" hcl:"group_vars"`
	HostVars            *string           `mapstructure:"host_vars" cty:"host_vars" hcl:"host_vars"`
	PlaybookDir         *string           `mapstructure:"playbook_dir" cty:"playbook_dir" hcl:"playbook_dir"`
	PlaybookFile        *string           `mapstructure:"playbook_file" cty:"playbook_file" hcl:"playbook_file"`
	PlaybookFiles       []string          `mapstructure:"playbook_files" cty:"playbook_files" hcl:"playbook_files"`
	PlaybookPaths       []string          `mapstructure:"playbook_paths" cty:"playbook_paths" hcl:"playbook_paths"`
	RolePaths           []string          `mapstructure:"role_paths" cty:"role_paths" hcl:"role_paths"`
	StagingDir          *string           `mapstructure:"staging_directory" cty:"staging_directory" hcl:"staging_directory"`
	CleanStagingDir     *bool             `mapstructure:"clean_staging_directory" cty:"clean_staging_directory" hcl:"clean_staging_directory"`
	InventoryFile       *string           `mapstructure:"inventory_file" cty:"inventory_file" hcl:"inventory_file"`
	InventoryGroups     []string          `mapstructure:"inventory_groups" cty:"inventory_groups" hcl:"inventory_groups"`
	GalaxyFile          *string           `mapstructure:"galaxy_file" cty:"galaxy_file" hcl:"galaxy_file"`
	GalaxyCommand       *string           `mapstructure:"galaxy_command" cty:"galaxy_command" hcl:"galaxy_command"`
}

FlatConfig is an auto-generated flat version of Config. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatConfig) HCL2Spec

func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a Config. This spec is used by HCL to read the fields of Config. The decoded values from this spec will then be applied to a FlatConfig.

type Provisioner

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

func (*Provisioner) ConfigSpec

func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec

func (*Provisioner) Prepare

func (p *Provisioner) Prepare(raws ...interface{}) error

func (*Provisioner) Provision

func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error

Jump to

Keyboard shortcuts

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