arm

package
Version: v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: MPL-2.0, MIT Imports: 29 Imported by: 0

README

packer-azure-arm

The ARM flavor of packer-azure utilizes the Azure Resource Manager APIs. Please see the overview for more information about ARM as well as the benefit of ARM.

Getting Started

The ARM APIs use OAUTH to authenticate, so you must create a Service Principal. The following articles are a good starting points.

There are three pieces of configuration you will need as a result of creating a Service Principal.

  1. Client ID (aka Service Principal ID)
  2. Client Secret (aka Service Principal generated key)
  3. Client Tenant (aka Azure Active Directory tenant that owns the Service Principal)

You will also need the following.

  1. Subscription ID
  2. Resource Group
  3. Storage Account

Resource Group is where your storage account is located, and Storage Account is where the created packer image will be stored.

The Service Principal has been tested with the following permissions. Please review the document for the built in roles for more details.

  • Owner

NOTE: the Owner role is too powerful, and more explicit set of roles is TBD. Issue #183 is tracking this work.

Sample Ubuntu

The following is a sample Packer template for use with the Packer Azure for ARM builder.

{
    "variables": {
        "cid": "your_client_id",
        "cst": "your_client_secret",
        "tid": "your_client_tenant",
        "sid": "your_subscription_id",

        "rgn": "your_resource_group",
        "sa": "your_storage_account"
    },
    "builders": [
        {
            "type": "azure-arm",

            "client_id": "{{user `cid`}}",
            "client_secret": "{{user `cst`}}",
            "subscription_id": "{{user `sid`}}",
            "tenant_id": "{{user `tid`}}",

            "capture_container_name": "images",
            "capture_name_prefix": "my_prefix",

            "image_publisher": "Canonical",
            "image_offer": "UbuntuServer",
            "image_sku": "14.04.3-LTS",

            "location": "South Central US",

            "resource_group_name": "{{user `rgn`}}",
            "storage_account": "{{user `sa`}}",

            "vm_size": "Standard_A1"
        }
    ],
    "provisioners": [
        {
            "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
            "inline": [
                "sudo apt-get update",
            ],
            "inline_shebang": "/bin/sh -x",
            "type": "shell"
        }
    ]
}

Using the above template, Packer would be invoked as follows.

NOTE: the following variables must be changed based on your subscription. These values are just dummy values, but they match format of expected, e.g. if the value is a GUID the sample is a GUID.

packer build^
  -var cid="593c4dc4-9cd7-49af-9fe0-1ea5055ac1e4"^
  -var cst="GbzJfsfrVkqL/TLfZY8TXA=="^
  -var sid="ce323e74-56fc-4bd6-aa18-83b6dc262748"^
  -var tid="da3847b4-8e69-40bd-a2c2-41da6982c5e2"^
  -var rgn="My Resource Group"^
  -var sa="mystorageaccount"^
  c:\packer\ubuntu_14_LTS.json

Please see the config_sameples/arm directory for more examples of usage.

Documentation

Index

Constants

View Source
const (
	DefaultUserName = "packer"
	DefaultVMSize   = "Standard_A1"
)
View Source
const (
	DeployCanceled  = "Canceled"
	DeployFailed    = "Failed"
	DeployDeleted   = "Deleted"
	DeploySucceeded = "Succeeded"
)
View Source
const (
	TempNameAlphabet     = "0123456789bcdfghjklmnpqrstvwxyz"
	TempPasswordAlphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
View Source
const (
	BuilderId = "Azure.ResourceManagement.VMImage"
)
View Source
const (
	DefaultPublicIPAddressName = "packerPublicIP"
)
View Source
const (
	KeySize = 2048
)
View Source
const Linux = `` /* 5242-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureClient

func NewAzureClient

func NewAzureClient(subscriptionID string, resourceGroupName string, storageAccountName string, servicePrincipalToken *azure.ServicePrincipalToken) (*AzureClient, error)

type Builder

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

func (*Builder) Cancel

func (b *Builder) Cancel()

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, error)

func (*Builder) Run

func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error)

type Config

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

	// Authentication via OAUTH
	ClientID       string `mapstructure:"client_id"`
	ClientSecret   string `mapstructure:"client_secret"`
	TenantID       string `mapstructure:"tenant_id"`
	SubscriptionID string `mapstructure:"subscription_id"`

	// Capture
	CaptureNamePrefix    string `mapstructure:"capture_name_prefix"`
	CaptureContainerName string `mapstructure:"capture_container_name"`

	// Compute
	ImagePublisher string `mapstructure:"image_publisher"`
	ImageOffer     string `mapstructure:"image_offer"`
	ImageSku       string `mapstructure:"image_sku"`
	Location       string `mapstructure:"location"`
	VMSize         string `mapstructure:"vm_size"`

	// Deployment
	ResourceGroupName string `mapstructure:"resource_group_name"`
	StorageAccount    string `mapstructure:"storage_account"`

	// Runtime Values
	UserName string
	Password string

	Comm communicator.Config `mapstructure:",squash"`
	// contains filtered or unexported fields
}

type DeploymentFactory

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

type DeploymentPoller

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

func NewDeploymentPoller

func NewDeploymentPoller(getProvisioningState func() (string, error)) *DeploymentPoller

func (*DeploymentPoller) PollAsNeeded

func (t *DeploymentPoller) PollAsNeeded() (string, error)

type OpenSshKeyPair

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

func NewOpenSshKeyPair

func NewOpenSshKeyPair() (*OpenSshKeyPair, error)

func NewOpenSshKeyPairWithSize

func NewOpenSshKeyPairWithSize(keySize int) (*OpenSshKeyPair, error)

func (*OpenSshKeyPair) AuthorizedKey

func (s *OpenSshKeyPair) AuthorizedKey() string

func (*OpenSshKeyPair) PrivateKey

func (s *OpenSshKeyPair) PrivateKey() string

type StepCaptureImage

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

func NewStepCaptureImage

func NewStepCaptureImage(client *AzureClient, ui packer.Ui) *StepCaptureImage

func (*StepCaptureImage) Cleanup

func (*StepCaptureImage) Run

type StepCreateResourceGroup

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

func NewStepCreateResourceGroup

func NewStepCreateResourceGroup(client *AzureClient, ui packer.Ui) *StepCreateResourceGroup

func (*StepCreateResourceGroup) Cleanup

func (*StepCreateResourceGroup) Run

type StepDeleteOSDisk

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

func NewStepDeleteOSDisk

func NewStepDeleteOSDisk(client *AzureClient, ui packer.Ui) *StepDeleteOSDisk

func (*StepDeleteOSDisk) Cleanup

func (*StepDeleteOSDisk) Run

type StepDeleteResourceGroup

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

func NewStepDeleteResourceGroup

func NewStepDeleteResourceGroup(client *AzureClient, ui packer.Ui) *StepDeleteResourceGroup

func (*StepDeleteResourceGroup) Cleanup

func (*StepDeleteResourceGroup) Run

type StepDeployTemplate

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

func NewStepDeployTemplate

func NewStepDeployTemplate(client *AzureClient, ui packer.Ui) *StepDeployTemplate

func (*StepDeployTemplate) Cleanup

func (*StepDeployTemplate) Run

type StepGetIPAddress

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

func NewStepGetIPAddress

func NewStepGetIPAddress(client *AzureClient, ui packer.Ui) *StepGetIPAddress

func (*StepGetIPAddress) Cleanup

func (*StepGetIPAddress) Run

type StepGetOSDisk

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

func NewStepGetOSDisk

func NewStepGetOSDisk(client *AzureClient, ui packer.Ui) *StepGetOSDisk

func (*StepGetOSDisk) Cleanup

func (*StepGetOSDisk) Cleanup(multistep.StateBag)

func (*StepGetOSDisk) Run

type StepPowerOffCompute

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

func NewStepPowerOffCompute

func NewStepPowerOffCompute(client *AzureClient, ui packer.Ui) *StepPowerOffCompute

func (*StepPowerOffCompute) Cleanup

func (*StepPowerOffCompute) Run

type StepValidateTemplate

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

func NewStepValidateTemplate

func NewStepValidateTemplate(client *AzureClient, ui packer.Ui) *StepValidateTemplate

func (*StepValidateTemplate) Cleanup

func (*StepValidateTemplate) Run

type TempName

type TempName struct {
	AdminPassword     string
	ComputeName       string
	DeploymentName    string
	ResourceGroupName string
	OSDiskName        string
}

func NewTempName

func NewTempName() *TempName

type TemplateParameter

type TemplateParameter struct {
	Value string `json:"value"`
}

type TemplateParameters

type TemplateParameters struct {
	AdminUsername      *TemplateParameter `json:"adminUsername,omitempty"`
	AdminPassword      *TemplateParameter `json:"adminPassword,omitempty"`
	DnsNameForPublicIP *TemplateParameter `json:"dnsNameForPublicIP,omitempty"`
	ImageOffer         *TemplateParameter `json:"imageOffer,omitempty"`
	ImagePublisher     *TemplateParameter `json:"imagePublisher,omitempty"`
	ImageSku           *TemplateParameter `json:"imageSku,omitempty"`
	OSDiskName         *TemplateParameter `json:"osDiskName,omitempty"`
	SshAuthorizedKey   *TemplateParameter `json:"sshAuthorizedKey,omitempty"`
	StorageAccountName *TemplateParameter `json:"storageAccountName,omitempty"`
	VMSize             *TemplateParameter `json:"vmSize,omitempty"`
	VMName             *TemplateParameter `json:"vmName,omitempty"`
}

Jump to

Keyboard shortcuts

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