mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-21 15:31:41 -04:00
* 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
51 lines
1.1 KiB
Plaintext
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.
|