docs: put hcl2 example in first tab

pull/13243/head
Martin Grogan 1 year ago committed by Lucas Bajolet
parent b6141fd532
commit 5940ab6d64

@ -25,17 +25,6 @@ Below is a fully functioning example. It create a file at `target` with the
specified `content`.
<Tabs>
<Tab heading="JSON">
```json
{
"type": "file",
"content": "Lorem ipsum dolor sit amet",
"target": "dummy_artifact"
}
```
</Tab>
<Tab heading="HCL2">
```hcl
@ -49,6 +38,17 @@ build {
}
```
</Tab>
<Tab heading="JSON">
```json
{
"type": "file",
"content": "Lorem ipsum dolor sit amet",
"target": "dummy_artifact"
}
```
</Tab>
</Tabs>

@ -26,18 +26,6 @@ Below is a fully functioning example. It doesn't do anything useful, since no
provisioners are defined, but it will connect to the specified host via ssh.
<Tabs>
<Tab heading="JSON">
```json
{
"type": "null",
"ssh_host": "127.0.0.1",
"ssh_username": "foo",
"ssh_password": "bar"
}
```
</Tab>
<Tab heading="HCL2">
```hcl
@ -52,6 +40,18 @@ build {
}
```
</Tab>
<Tab heading="JSON">
```json
{
"type": "null",
"ssh_host": "127.0.0.1",
"ssh_username": "foo",
"ssh_password": "bar"
}
```
</Tab>
</Tabs>

@ -33,6 +33,16 @@ a third-party post-processor.
## Basic example
<Tabs>
<Tab heading="HCL2">
```hcl
post-processor "checksum" {
checksum_types = ["sha1", "sha256"]
output = "packer_{{.BuildName}}_{{.ChecksumType}}.checksum"
}
```
</Tab>
<Tab heading="JSON">
```json
@ -43,16 +53,6 @@ a third-party post-processor.
}
```
</Tab>
<Tab heading="HCL2">
```hcl
post-processor "checksum" {
checksum_types = ["sha1", "sha256"]
output = "packer_{{.BuildName}}_{{.ChecksumType}}.checksum"
}
```
</Tab>
</Tabs>

@ -48,6 +48,13 @@ is not a behavior anyone should ever expect.
The minimal way to use the manifest post-processor is by just writing its definition, like:
<Tabs>
<Tab heading="HCL2">
```hcl
post-processor "manifest" {}
```
</Tab>
<Tab heading="JSON">
```json
@ -61,18 +68,24 @@ The minimal way to use the manifest post-processor is by just writing its defini
```
</Tab>
</Tabs>
A more complete example:
<Tabs>
<Tab heading="HCL2">
```hcl
post-processor "manifest" {}
post-processor "manifest" {
output = "manifest.json"
strip_path = true
custom_data = {
my_custom_data = "example"
}
}
```
</Tab>
</Tabs>
A more complete example:
<Tabs>
<Tab heading="JSON">
```json
@ -90,19 +103,6 @@ A more complete example:
}
```
</Tab>
<Tab heading="HCL2">
```hcl
post-processor "manifest" {
output = "manifest.json"
strip_path = true
custom_data = {
my_custom_data = "example"
}
}
```
</Tab>
</Tabs>
@ -139,6 +139,29 @@ artifacts from the manifest by using `packer_run_uuid`.
The above manifest was generated with the following template:
<Tabs>
<Tab heading="HCL2">
```hcl
source "docker" "docker"{
image = "ubuntu:latest"
export_path = "packer_example"
run_command = ["-d", "-i", "-t", "--entrypoint=/bin/bash", "{{.Image}}"]
}
build {
sources = ["docker.docker"]
post-processor "manifest" {
output = "manifest.json"
strip_path = true
custom_data = {
my_custom_data = "example"
}
}
}
```
</Tab>
<Tab heading="JSON">
```json
@ -164,29 +187,6 @@ The above manifest was generated with the following template:
}
```
</Tab>
<Tab heading="HCL2">
```hcl
source "docker" "docker"{
image = "ubuntu:latest"
export_path = "packer_example"
run_command = ["-d", "-i", "-t", "--entrypoint=/bin/bash", "{{.Image}}"]
}
build {
sources = ["docker.docker"]
post-processor "manifest" {
output = "manifest.json"
strip_path = true
custom_data = {
my_custom_data = "example"
}
}
}
```
</Tab>
</Tabs>

@ -27,6 +27,30 @@ and between every provisioner.
## Basic Example
<Tabs>
<Tab heading="HCL2">
```hcl
source "null" "example" {
communicator = "none"
}
build {
sources = ["source.null.example"]
provisioner "shell-local" {
inline = ["echo hi"]
}
provisioner "breakpoint" {
disable = false
note = "this is a breakpoint"
}
provisioner "shell-local" {
inline = ["echo hi 2"]
}
}
```
</Tab>
<Tab heading="JSON">
```json
@ -55,30 +79,6 @@ and between every provisioner.
}
```
</Tab>
<Tab heading="HCL2">
```hcl
source "null" "example" {
communicator = "none"
}
build {
sources = ["source.null.example"]
provisioner "shell-local" {
inline = ["echo hi"]
}
provisioner "breakpoint" {
disable = false
note = "this is a breakpoint"
}
provisioner "shell-local" {
inline = ["echo hi 2"]
}
}
```
</Tab>
</Tabs>

@ -30,6 +30,16 @@ The file provisioner can upload both single files and complete directories.
## Basic Example
<Tabs>
<Tab heading="HCL2">
```hcl
provisioner "file" {
source = "app.tar.gz"
destination = "/tmp/app.tar.gz"
}
```
</Tab>
<Tab heading="JSON">
```json
@ -40,16 +50,6 @@ The file provisioner can upload both single files and complete directories.
}
```
</Tab>
<Tab heading="HCL2">
```hcl
provisioner "file" {
source = "app.tar.gz"
destination = "/tmp/app.tar.gz"
}
```
</Tab>
</Tabs>

@ -28,6 +28,40 @@ this example can be applied to other builders as well.
Here is an extremely basic virtualbox-iso template:
<Tabs>
<Tab heading="HCL2">
```hcl
source "virtualbox-iso" "step_1" {
boot_command = ["<esc><wait>", "<esc><wait>", "<enter><wait>",
"/install/vmlinuz<wait>", " initrd=/install/initrd.gz",
" auto-install/enable=true", " debconf/priority=critical",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu_preseed.cfg<wait>",
" -- <wait>", "<enter><wait>"]
disk_size = "40960"
guest_os_type = "Ubuntu_64"
http_directory = "./http"
iso_checksum = "sha256:946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2"
iso_url = "http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04-server-amd64.iso"
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now"
ssh_password = "vagrant"
ssh_port = 22
ssh_username = "vagrant"
vm_name = "vbox-example"
}
build {
sources = ["source.virtualbox-iso.step_1"]
provisioner "shell" {
inline = ["echo initial provisioning"]
}
post-processor "manifest" {
output = "stage-1-manifest.json"
}
}
```
</Tab>
<Tab heading="JSON">
```json
@ -77,40 +111,6 @@ Here is an extremely basic virtualbox-iso template:
}
```
</Tab>
<Tab heading="HCL2">
```hcl
source "virtualbox-iso" "step_1" {
boot_command = ["<esc><wait>", "<esc><wait>", "<enter><wait>",
"/install/vmlinuz<wait>", " initrd=/install/initrd.gz",
" auto-install/enable=true", " debconf/priority=critical",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu_preseed.cfg<wait>",
" -- <wait>", "<enter><wait>"]
disk_size = "40960"
guest_os_type = "Ubuntu_64"
http_directory = "./http"
iso_checksum = "sha256:946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2"
iso_url = "http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04-server-amd64.iso"
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now"
ssh_password = "vagrant"
ssh_port = 22
ssh_username = "vagrant"
vm_name = "vbox-example"
}
build {
sources = ["source.virtualbox-iso.step_1"]
provisioner "shell" {
inline = ["echo initial provisioning"]
}
post-processor "manifest" {
output = "stage-1-manifest.json"
}
}
```
</Tab>
</Tabs>
@ -138,6 +138,29 @@ That output filename generated in the first stage can be used as the
for the virtualbox-ovf builder.
<Tabs>
<Tab heading="HCL2">
```hcl
source "virtualbox-ovf" "step_2" {
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now"
source_path = "output-virtualbox-iso/vbox-example.ovf"
ssh_password = "vagrant"
ssh_port = 22
ssh_username = "vagrant"
vm_name = "virtualbox-example-ovf"
}
build {
sources = ["source.virtualbox-ovf.step_2"]
provisioner "shell" {
inline = ["echo secondary provisioning"]
}
}
```
</Tab>
<Tab heading="JSON">
```json
@ -164,29 +187,6 @@ for the virtualbox-ovf builder.
}
```
</Tab>
<Tab heading="HCL2">
```hcl
source "virtualbox-ovf" "step_2" {
shutdown_command = "echo 'vagrant' | sudo -S shutdown -P now"
source_path = "output-virtualbox-iso/vbox-example.ovf"
ssh_password = "vagrant"
ssh_port = 22
ssh_username = "vagrant"
vm_name = "virtualbox-example-ovf"
}
build {
sources = ["source.virtualbox-ovf.step_2"]
provisioner "shell" {
inline = ["echo secondary provisioning"]
}
}
```
</Tab>
</Tabs>
@ -203,6 +203,28 @@ being used with a null builder, and manually sets the artifact from our
stage-2 ovf build:
<Tabs>
<Tab heading="HCL2">
```hcl
source "null" "step_3" {
communicator = "none"
}
build {
sources = ["source.null.step_3"]
post-processors {
post-processor "artifice" {
files = ["output-virtualbox-ovf/virtualbox-example-ovf.ovf", "output-virtualbox-ovf/virtualbox-example-ovf-disk001.vmdk"]
}
post-processor "vagrant" {
provider_override = "virtualbox"
}
}
}
```
</Tab>
<Tab heading="JSON">
```json
@ -231,28 +253,6 @@ stage-2 ovf build:
}
```
</Tab>
<Tab heading="HCL2">
```hcl
source "null" "step_3" {
communicator = "none"
}
build {
sources = ["source.null.step_3"]
post-processors {
post-processor "artifice" {
files = ["output-virtualbox-ovf/virtualbox-example-ovf.ovf", "output-virtualbox-ovf/virtualbox-example-ovf-disk001.vmdk"]
}
post-processor "vagrant" {
provider_override = "virtualbox"
}
}
}
```
</Tab>
</Tabs>

Loading…
Cancel
Save