Files
Packer-Cn/website/pages/docs/from-1.5/blocks/build/source.mdx
T
Adrien Delorme 451d4c2620 hcl2 docs pass (#9375)
* moved blocks and functions top the nav list for easier access ( I think those will be used a lot)
* added a concrete fileset example
* added more concrete examples in the blocks doc
2020-06-09 12:42:01 +02:00

51 lines
1.1 KiB
Plaintext

---
description: >
A source block nested in a build block allows you to use an already defined
source and to set specific fields.
layout: docs
page_title: source - build - Blocks
sidebar_title: <tt>source</tt>
---
# The `source` block
`@include 'from-1.5/beta-hcl2-note.mdx'`
A `source` block nested in a `build` block allows to use an already defined
source and to set specific fields.
```hcl
# builds.pkr.hcl
source "lxd" "arch" {
image = "archlinux"
}
build {
source "lxd.arch" {
output_image = "nomad"
}
provisioner "shell" {
inline = [ "echo installing nomad" ]
}
}
build {
source "lxd.arch" {
output_image = "consul"
}
provisioner "shell" {
inline = [ "echo installing consul" ]
}
}
```
This allows to have commonly defined source settings with specific parts of it
defined inside the specific build block.
-> **Note:** It is **not allowed** to set the same field in a top-level source
block and in a used source block. For example, if in the above example, the
top-level "amazon-ebs.example" source block also had an `output` field;
Packer would error.