diff --git a/website/content/docs/builders/file.mdx b/website/content/docs/builders/file.mdx index 55f73d9b6..0fa02283c 100644 --- a/website/content/docs/builders/file.mdx +++ b/website/content/docs/builders/file.mdx @@ -25,17 +25,6 @@ Below is a fully functioning example. It create a file at `target` with the specified `content`. - - -```json -{ - "type": "file", - "content": "Lorem ipsum dolor sit amet", - "target": "dummy_artifact" -} -``` - - ```hcl @@ -49,6 +38,17 @@ build { } ``` + + + +```json +{ + "type": "file", + "content": "Lorem ipsum dolor sit amet", + "target": "dummy_artifact" +} +``` + diff --git a/website/content/docs/builders/null.mdx b/website/content/docs/builders/null.mdx index 2098fec67..9a0f1542d 100644 --- a/website/content/docs/builders/null.mdx +++ b/website/content/docs/builders/null.mdx @@ -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. - - -```json -{ - "type": "null", - "ssh_host": "127.0.0.1", - "ssh_username": "foo", - "ssh_password": "bar" -} -``` - - ```hcl @@ -52,6 +40,18 @@ build { } ``` + + + +```json +{ + "type": "null", + "ssh_host": "127.0.0.1", + "ssh_username": "foo", + "ssh_password": "bar" +} +``` + diff --git a/website/content/docs/post-processors/checksum.mdx b/website/content/docs/post-processors/checksum.mdx index 0f8056c64..b6db82253 100644 --- a/website/content/docs/post-processors/checksum.mdx +++ b/website/content/docs/post-processors/checksum.mdx @@ -33,6 +33,16 @@ a third-party post-processor. ## Basic example + + +```hcl +post-processor "checksum" { + checksum_types = ["sha1", "sha256"] + output = "packer_{{.BuildName}}_{{.ChecksumType}}.checksum" +} +``` + + ```json @@ -43,16 +53,6 @@ a third-party post-processor. } ``` - - - -```hcl -post-processor "checksum" { - checksum_types = ["sha1", "sha256"] - output = "packer_{{.BuildName}}_{{.ChecksumType}}.checksum" -} -``` - diff --git a/website/content/docs/post-processors/manifest.mdx b/website/content/docs/post-processors/manifest.mdx index 839c940cb..77a2c8838 100644 --- a/website/content/docs/post-processors/manifest.mdx +++ b/website/content/docs/post-processors/manifest.mdx @@ -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: + + +```hcl +post-processor "manifest" {} +``` + + ```json @@ -61,18 +68,24 @@ The minimal way to use the manifest post-processor is by just writing its defini ``` + + +A more complete example: + + ```hcl -post-processor "manifest" {} +post-processor "manifest" { + output = "manifest.json" + strip_path = true + custom_data = { + my_custom_data = "example" + } +} ``` - - -A more complete example: - - ```json @@ -90,19 +103,6 @@ A more complete example: } ``` - - - -```hcl -post-processor "manifest" { - output = "manifest.json" - strip_path = true - custom_data = { - my_custom_data = "example" - } -} -``` - @@ -139,6 +139,29 @@ artifacts from the manifest by using `packer_run_uuid`. The above manifest was generated with the following template: + + +```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" + } + } +} +``` + + ```json @@ -164,29 +187,6 @@ The above manifest was generated with the following template: } ``` - - - -```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" - } - } -} -``` - diff --git a/website/content/docs/provisioners/breakpoint.mdx b/website/content/docs/provisioners/breakpoint.mdx index b7585fd67..97e9ffd6b 100644 --- a/website/content/docs/provisioners/breakpoint.mdx +++ b/website/content/docs/provisioners/breakpoint.mdx @@ -27,6 +27,30 @@ and between every provisioner. ## Basic Example + + +```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"] + } +} +``` + + ```json @@ -55,30 +79,6 @@ and between every provisioner. } ``` - - - -```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"] - } -} -``` - diff --git a/website/content/docs/provisioners/file.mdx b/website/content/docs/provisioners/file.mdx index e123be997..08e2f36fd 100644 --- a/website/content/docs/provisioners/file.mdx +++ b/website/content/docs/provisioners/file.mdx @@ -30,6 +30,16 @@ The file provisioner can upload both single files and complete directories. ## Basic Example + + +```hcl +provisioner "file" { + source = "app.tar.gz" + destination = "/tmp/app.tar.gz" +} +``` + + ```json @@ -40,16 +50,6 @@ The file provisioner can upload both single files and complete directories. } ``` - - - -```hcl -provisioner "file" { - source = "app.tar.gz" - destination = "/tmp/app.tar.gz" -} -``` - diff --git a/website/content/guides/packer-on-cicd/pipelineing-builds.mdx b/website/content/guides/packer-on-cicd/pipelineing-builds.mdx index 2a7e69210..e9605d434 100644 --- a/website/content/guides/packer-on-cicd/pipelineing-builds.mdx +++ b/website/content/guides/packer-on-cicd/pipelineing-builds.mdx @@ -28,6 +28,40 @@ this example can be applied to other builders as well. Here is an extremely basic virtualbox-iso template: + + +```hcl +source "virtualbox-iso" "step_1" { + boot_command = ["", "", "", + "/install/vmlinuz", " initrd=/install/initrd.gz", + " auto-install/enable=true", " debconf/priority=critical", + " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu_preseed.cfg", + " -- ", ""] + 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" + } +} +``` + + ```json @@ -77,40 +111,6 @@ Here is an extremely basic virtualbox-iso template: } ``` - - - -```hcl -source "virtualbox-iso" "step_1" { - boot_command = ["", "", "", - "/install/vmlinuz", " initrd=/install/initrd.gz", - " auto-install/enable=true", " debconf/priority=critical", - " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu_preseed.cfg", - " -- ", ""] - 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" - } -} -``` - @@ -138,6 +138,29 @@ That output filename generated in the first stage can be used as the for the virtualbox-ovf builder. + + +```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"] + } +} + +``` + + ```json @@ -164,29 +187,6 @@ for the virtualbox-ovf builder. } ``` - - - -```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"] - } -} - -``` - @@ -203,6 +203,28 @@ being used with a null builder, and manually sets the artifact from our stage-2 ovf build: + + +```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" + } + } +} +``` + + ```json @@ -231,28 +253,6 @@ stage-2 ovf build: } ``` - - - -```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" - } - } -} -``` -