add example

This commit is contained in:
Paul Meyer 2019-10-02 23:52:55 +00:00
parent cf8688ec40
commit 37931c551f
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,26 @@
{
"variables": {
"client_id": "{{env `ARM_CLIENT_ID`}}",
"client_secret": "{{env `ARM_CLIENT_SECRET`}}",
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}"
},
"builders": [{
"type": "azure-chroot",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"subscription_id": "{{user `subscription_id`}}",
"image_resource_id": "/subscriptions/{{user `subscription_id`}}/resourceGroups/{{user `resource_group`}}/providers/Microsoft.Compute/images/MyDebianOSImage-{{timestamp}}",
"source": "credativ:Debian:9:latest"
}],
"provisioners": [{
"inline": [
"apt-get update",
"apt-get upgrade -y"
],
"inline_shebang": "/bin/sh -x",
"type": "shell"
}]
}

View File

@ -101,3 +101,40 @@ mounts `/prod` and `/dev`:
- The mount directory. - The mount directory.
## Example
Here is an example that creates a Debian image with updated packages. Specify
all environment variables (`ARM_CLIENT_ID`, `ARM_CLIENT_SECRET`,
`ARM_SUBSCRIPTION_ID`) to use a service principal, specify only `ARM_SUBSCRIPTION_ID`
to use interactive login or leave them empty to use the system-assigned identity
of the VM you run Packer on.
The identity you choose should have permission to create disks and images and also
to update your VM.
``` json
{
"variables": {
"client_id": "{{env `ARM_CLIENT_ID`}}",
"client_secret": "{{env `ARM_CLIENT_SECRET`}}",
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}"
},
"builders": [{
"type": "azure-chroot",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"subscription_id": "{{user `subscription_id`}}",
"image_resource_id": "/subscriptions/{{user `subscription_id`}}/resourceGroups/{{user `resource_group`}}/providers/Microsoft.Compute/images/MyDebianOSImage-{{timestamp}}",
"source": "credativ:Debian:9:latest"
}],
"provisioners": [{
"inline": [
"apt-get update",
"apt-get upgrade -y"
],
"inline_shebang": "/bin/sh -x",
"type": "shell"
}]
}
```