website/content/docs/templates/hcl_templates/path-variables.mdx
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
[!IMPORTANT]
Documentation Update: Product documentation previously located in/websitehas moved to thehashicorp/web-unified-docsrepository, where all product documentation is now centralized. Please make contributions directly toweb-unified-docs, since changes to/websitein this repository will not appear on developer.hashicorp.com. ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
This topic provides reference information about path variables for Packer templates written in HCL.
Use the following variables to build paths:
path.cwd: the directory from where Packer was started.
path.root: the directory of the input HCL file or the input folder.
locals {
settings_file = "${path.cwd}/settings.txt"
scripts_folder = "${path.root}/scripts"
root = path.root
}
@include 'path/separator-note.mdx'
abspath takes a string containing
a filesystem path and converts it to an absolute path.
basename returns only the last
portion of a filesystem path, discarding the portion that would be returned
by dirname.
fileset enumerates a set of
regular file names given a path and pattern.
dirname returns all of the
segments of a filesystem path except the last, discarding the portion that
would be returned by basename.