5b5888b230 | ||
---|---|---|
.. | ||
README.md | ||
artifact.go | ||
azure_client.go | ||
builder.go | ||
builder_test.go | ||
config.go | ||
config_test.go | ||
deployment_factory.go | ||
deployment_factory_test.go | ||
deployment_poller.go | ||
deployment_poller_test.go | ||
openssh_key_pair.go | ||
openssh_key_pair_test.go | ||
step_capture_image.go | ||
step_capture_image_test.go | ||
step_create_resource_group.go | ||
step_create_resource_group_test.go | ||
step_delete_os_disk.go | ||
step_delete_os_disk_test.go | ||
step_delete_resource_group.go | ||
step_delete_resource_group_test.go | ||
step_deploy_template.go | ||
step_deploy_template_test.go | ||
step_get_ip_address.go | ||
step_get_ip_address_test.go | ||
step_get_os_disk.go | ||
step_get_os_disk_test.go | ||
step_power_off_compute.go | ||
step_power_off_compute_test.go | ||
step_validate_template.go | ||
step_validate_template_test.go | ||
template.go | ||
template_parameters.go | ||
template_parameters_test.go | ||
tempname.go | ||
tempname_test.go |
README.md
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.
- Automating Azure on your CI server using a Service Principal
- Authenticating a service principal with Azure Resource Manager
There are three pieces of configuration you will need as a result of creating a Service Principal.
- Client ID (aka Service Principal ID)
- Client Secret (aka Service Principal generated key)
- Client Tenant (aka Azure Active Directory tenant that owns the Service Principal)
You will also need the following.
- Subscription ID
- Resource Group
- 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.