diff --git a/website/content/docs/builders/amazon/index.mdx b/website/content/docs/builders/amazon/index.mdx
index 3039471be..d5e34da1a 100644
--- a/website/content/docs/builders/amazon/index.mdx
+++ b/website/content/docs/builders/amazon/index.mdx
@@ -116,7 +116,7 @@ Usage:
$ export AWS_ACCESS_KEY_ID="anaccesskey"
$ export AWS_SECRET_ACCESS_KEY="asecretkey"
$ export AWS_DEFAULT_REGION="us-west-2"
- $ packer build packer.json
+ $ packer build template.pkr.hcl
### Shared Credentials file
diff --git a/website/content/docs/builders/azure/chroot.mdx b/website/content/docs/builders/azure/chroot.mdx
index b49cb777b..d9d9feaf5 100644
--- a/website/content/docs/builders/azure/chroot.mdx
+++ b/website/content/docs/builders/azure/chroot.mdx
@@ -155,7 +155,7 @@ This builder requires privileged actions, such as mounting disks, running
permissions, for example:
```shell-session
-$ sudo -E packer build example.json
+$ sudo -E packer build example.pkr.json
```
### Using a VM with a Managed Identity
@@ -164,6 +164,30 @@ On a VM with a system-assigned managed identity that has the contributor role
on its own resource group, the following config can be used to create an
updated Debian image:
+
+
+
+
+```hcl
+source "azure-chroot" "example" {
+ image_resource_id = "/subscriptions/{{vm `subscription_id`}}/resourceGroups/{{vm `resource_group`}}/providers/Microsoft.Compute/images/MyDebianOSImage-{{timestamp}}"
+ source = "credativ:Debian:9:latest"
+}
+
+build {
+ sources = ["source.azure-chroot.example"]
+
+ provisioner "shell" {
+ inline = ["apt-get update", "apt-get upgrade -y"]
+ inline_shebang = "/bin/sh -x"
+ }
+}
+```
+
+
+
+
+
```json
{
"builders": [
@@ -184,6 +208,9 @@ updated Debian image:
}
```
+
+
+
### Using a Service Principal
Here is an example that creates a Debian image with updated packages. Specify
@@ -195,40 +222,6 @@ Set the `ARM_IMAGE_RESOURCEGROUP_ID` variable to an existing resource group in t
subscription where the resulting image will be created.
-
-
-```json
-{
- "variables": {
- "client_id": "{{env `ARM_CLIENT_ID`}}",
- "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
- "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
- "resource_group": "{{env `ARM_IMAGE_RESOURCEGROUP_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"
- }
- ]
-}
-```
-
-
```hcl
@@ -265,5 +258,39 @@ build {
}
```
+
+
+
+ ```json
+ {
+ "variables": {
+ "client_id": "{{env `ARM_CLIENT_ID`}}",
+ "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
+ "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
+ "resource_group": "{{env `ARM_IMAGE_RESOURCEGROUP_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"
+ }
+ ]
+ }
+ ```
+
diff --git a/website/content/docs/builders/outscale/index.mdx b/website/content/docs/builders/outscale/index.mdx
index bc085c880..9b7d7bcae 100644
--- a/website/content/docs/builders/outscale/index.mdx
+++ b/website/content/docs/builders/outscale/index.mdx
@@ -75,7 +75,7 @@ Usage:
$ export OUTSCALE_ACCESSKEYID="anaccesskey"
$ export OUTSCALE_SECRETKEYID="asecretkey"
$ export OUTSCALE_REGION="eu-west-2"
- $ packer build packer.json
+ $ packer build template.pkr.hcl
### x509 Certificate Authentication
diff --git a/website/content/docs/commands/validate.mdx b/website/content/docs/commands/validate.mdx
index 85f034c74..5083fb401 100644
--- a/website/content/docs/commands/validate.mdx
+++ b/website/content/docs/commands/validate.mdx
@@ -19,7 +19,7 @@ outputted.
Example usage:
```shell-session
-$ packer validate my-template.json
+$ packer validate my-template.pkr.hcl
Template validation failed. Errors are shown below.
Errors validating build 'vmware'. 1 error(s) occurred:
diff --git a/website/content/docs/post-processors/googlecompute-import.mdx b/website/content/docs/post-processors/googlecompute-import.mdx
index 162c6d2e0..cbc611cfe 100644
--- a/website/content/docs/post-processors/googlecompute-import.mdx
+++ b/website/content/docs/post-processors/googlecompute-import.mdx
@@ -49,6 +49,18 @@ compressed raw disk image artifact for us to work with, and that the GCS bucket
has been created.
+
+
+```hcl
+post-processor "googlecompute-import"{
+ account_file = "account.json"
+ bucket = "my-bucket"
+ project_id = "my-project"
+ image_name = "my-gce-image"
+}
+```
+
+
```json
@@ -61,19 +73,6 @@ has been created.
}
```
-
-
-
-
-```hcl
-post-processor "googlecompute-import"{
- account_file = "account.json"
- bucket = "my-bucket"
- project_id = "my-project"
- image_name = "my-gce-image"
-}
-```
-
@@ -82,72 +81,10 @@ post-processor "googlecompute-import"{
Here is a complete example for building a Fedora 31 server GCE image. For this
example Packer was run from a Debian Linux host with KVM installed.
- $ packer build -var serial=$(tty) build.json
+ $ packer build -var serial=$(tty) build.pkr.hcl
-
-
-```json
-{
- "variables": {
- "account_file": "account.json",
- "bucket": "my-bucket",
- "project": "my-project",
- "serial": ""
- },
- "builders": [
- {
- "type": "qemu",
- "accelerator": "kvm",
- "boot_command": [
- " console=ttyS0,115200n8 inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/fedora-31-ks.cfg rd.live.check=0"
- ],
- "disk_size": "15000",
- "format": "raw",
- "iso_checksum": "sha256:225ebc160e40bb43c5de28bad9680e3a78a9db40c9e3f4f42f3ee3f10f95dbeb",
- "iso_url": "https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Server/x86_64/iso/Fedora-Server-dvd-x86_64-31-1.9.iso",
- "headless": "true",
- "http_directory": "http",
- "http_port_max": "10089",
- "http_port_min": "10082",
- "output_directory": "output",
- "shutdown_timeout": "30m",
- "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
- "ssh_username": "vagrant",
- "ssh_password": "vagrant",
- "vm_name": "disk.raw",
- "qemu_binary": "/usr/bin/kvm",
- "qemuargs": [
- ["-m", "1024"],
- ["-cpu", "host"],
- ["-chardev", "tty,id=pts,path={{user `serial`}}"],
- ["-device", "isa-serial,chardev=pts"],
- ["-device", "virtio-net,netdev=user.0"]
- ]
- }
- ],
- "post-processors": [
- [
- {
- "type": "compress",
- "output": "output/disk.raw.tar.gz"
- },
- {
- "type": "googlecompute-import",
- "project_id": "{{user `project`}}",
- "account_file": "{{user `account_file`}}",
- "bucket": "{{user `bucket`}}",
- "image_name": "fedora31-server-packertest",
- "image_description": "Fedora 31 Server",
- "image_family": "fedora31-server"
- }
- ]
- ]
-}
-```
-
-
-
+
```hcl
variables {
@@ -205,5 +142,67 @@ build {
}
```
+
+
+
+ ```json
+ {
+ "variables": {
+ "account_file": "account.json",
+ "bucket": "my-bucket",
+ "project": "my-project",
+ "serial": ""
+ },
+ "builders": [
+ {
+ "type": "qemu",
+ "accelerator": "kvm",
+ "boot_command": [
+ " console=ttyS0,115200n8 inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/fedora-31-ks.cfg rd.live.check=0"
+ ],
+ "disk_size": "15000",
+ "format": "raw",
+ "iso_checksum": "sha256:225ebc160e40bb43c5de28bad9680e3a78a9db40c9e3f4f42f3ee3f10f95dbeb",
+ "iso_url": "https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Server/x86_64/iso/Fedora-Server-dvd-x86_64-31-1.9.iso",
+ "headless": "true",
+ "http_directory": "http",
+ "http_port_max": "10089",
+ "http_port_min": "10082",
+ "output_directory": "output",
+ "shutdown_timeout": "30m",
+ "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
+ "ssh_username": "vagrant",
+ "ssh_password": "vagrant",
+ "vm_name": "disk.raw",
+ "qemu_binary": "/usr/bin/kvm",
+ "qemuargs": [
+ ["-m", "1024"],
+ ["-cpu", "host"],
+ ["-chardev", "tty,id=pts,path={{user `serial`}}"],
+ ["-device", "isa-serial,chardev=pts"],
+ ["-device", "virtio-net,netdev=user.0"]
+ ]
+ }
+ ],
+ "post-processors": [
+ [
+ {
+ "type": "compress",
+ "output": "output/disk.raw.tar.gz"
+ },
+ {
+ "type": "googlecompute-import",
+ "project_id": "{{user `project`}}",
+ "account_file": "{{user `account_file`}}",
+ "bucket": "{{user `bucket`}}",
+ "image_name": "fedora31-server-packertest",
+ "image_description": "Fedora 31 Server",
+ "image_family": "fedora31-server"
+ }
+ ]
+ ]
+ }
+ ```
+
diff --git a/website/content/guides/workflow-tips-and-tricks/use-packer-with-comment.mdx b/website/content/guides/workflow-tips-and-tricks/use-packer-with-comment.mdx
index 40acaa673..0a7b4a637 100644
--- a/website/content/guides/workflow-tips-and-tricks/use-packer-with-comment.mdx
+++ b/website/content/guides/workflow-tips-and-tricks/use-packer-with-comment.mdx
@@ -11,9 +11,10 @@ description: |-
-> **Note:** Packer supports HCL2 from version 1.6.0, the Hashicorp Configuration
Language allows to comment directly in template files. Consider upgrading your
-json template to hcl2 using the `packer hcl2_upgrade` command.
+JSON template to HCL2 using the `packer hcl2_upgrade` command.
-One of the biggest complaints we get about packer is that json doesn't use comments. We're in the process of moving to HCL2, the same config language used by Terraform, which does allow comments. But in the meantime, you can add detailed comments beyond the root-level underscore-prefixed field supported by Packer, and remove them using jq.
+One of the biggest complaints we get about Packer is that JSON doesn't use comments.
+For Packer JSON templates, you can add detailed comments beyond the root-level underscore-prefixed field supported by Packer, and remove them using jq.
Let's say we have a file named `commented_template.json`