mirror of
https://github.com/kemko/nomad.git
synced 2026-01-02 16:35:44 +03:00
* Move commands from docs to its own root-level directory * temporarily use modified dev-portal branch with nomad ia changes * explicitly clone nomad ia exp branch * retrigger build, fixed dev-portal broken build * architecture, concepts and get started individual pages * fix get started section destinations * reference section * update repo comment in website-build.sh to show branch * docs nav file update capitalization * update capitalization to force deploy * remove nomad-vs-kubernetes dir; move content to what is nomad pg * job section * Nomad operations category, deploy section * operations category, govern section * operations - manage * operations/scale; concepts scheduling fix * networking * monitor * secure section * remote auth-methods folder and move up pages to sso; linkcheck * Fix install2deploy redirects * fix architecture redirects * Job section: Add missing section index pages * Add section index pages so breadcrumbs build correctly * concepts/index fix front matter indentation * move task driver plugin config to new deploy section * Finish adding full URL to tutorials links in nav * change SSO to Authentication in nav and file system * Docs NomadIA: Move tutorials into NomadIA branch (#26132) * Move governance and policy from tutorials to docs * Move tutorials content to job-declare section * run jobs section * stateful workloads * advanced job scheduling * deploy section * manage section * monitor section * secure/acl and secure/authorization * fix example that contains an unseal key in real format * remove images from sso-vault * secure/traffic * secure/workload-identities * vault-acl change unseal key and root token in command output sample * remove lines from sample output * fix front matter * move nomad pack tutorials to tools * search/replace /nomad/tutorials links * update acl overview with content from deleted architecture/acl * fix spelling mistake * linkcheck - fix broken links * fix link to Nomad variables tutorial * fix link to Prometheus tutorial * move who uses Nomad to use cases page; move spec/config shortcuts add dividers * Move Consul out of Integrations; move namespaces to govern * move integrations/vault to secure/vault; delete integrations * move ref arch to docs; rename Deploy Nomad back to Install Nomad * address feedback * linkcheck fixes * Fixed raw_exec redirect * add info from /nomad/tutorials/manage-jobs/jobs * update page content with newer tutorial * link updates for architecture sub-folders * Add redirects for removed section index pages. Fix links. * fix broken links from linkcheck * Revert to use dev-portal main branch instead of nomadIA branch * build workaround: add intro-nav-data.json with single entry * fix content-check error * add intro directory to get around Vercel build error * workound for emtpry directory * remove mdx from /intro/ to fix content-check and git snafu * Add intro index.mdx so Vercel build should work --------- Co-authored-by: Tu Nguyen <im2nguyen@gmail.com>
115 lines
4.1 KiB
Plaintext
115 lines
4.1 KiB
Plaintext
---
|
|
layout: docs
|
|
page_title: HCL syntax reference
|
|
description: |-
|
|
HCL has its own syntax, intended to combine declarative
|
|
structure with expressions in a way that is easy for humans to read and
|
|
understand.
|
|
---
|
|
|
|
# HCL syntax reference
|
|
|
|
Other pages in this section have described various configuration constructs
|
|
that can appear in HCL. This page describes the lower-level syntax of the
|
|
language in more detail, revealing the building blocks that those constructs
|
|
are built from.
|
|
|
|
This page describes the _native syntax_ of HCL, which is a rich language
|
|
designed to be easy for humans to read and write.
|
|
|
|
This low-level syntax of HCL is defined in terms of a syntax called _HCL_,
|
|
which is also used by configuration languages in other applications, and in
|
|
particular other HashiCorp products. It is not necessary to know all of the
|
|
details of HCL in order to use Nomad, and so this page summarizes the most
|
|
important details. If you are interested, you can find a full definition of HCL
|
|
syntax in [the HCL native syntax
|
|
specification](https://github.com/hashicorp/hcl/blob/hcl2/hclsyntax/spec.md).
|
|
|
|
## Arguments and Blocks
|
|
|
|
HCL syntax is built around two key syntax constructs:
|
|
arguments and blocks.
|
|
|
|
### Arguments
|
|
|
|
An _argument_ assigns a value to a particular name:
|
|
|
|
```hcl
|
|
image_id = "nginx:1.19"
|
|
```
|
|
|
|
The identifier before the equals sign is the _argument name_, and the expression
|
|
after the equals sign is the argument's value.
|
|
|
|
The context where the argument appears determines what value types are valid
|
|
(for example, each job block type has a schema that defines the types of its
|
|
arguments), but many arguments accept arbitrary
|
|
[expressions](/nomad/docs/reference/hcl2/expressions), which allow the value to
|
|
either be specified literally or generated from other values programmatically.
|
|
|
|
### Blocks
|
|
|
|
A _block_ is a container for other content:
|
|
|
|
```hcl
|
|
task "webserver" {
|
|
driver = "docker"
|
|
|
|
config {
|
|
# ...
|
|
}
|
|
}
|
|
```
|
|
|
|
A block has a _type_ (`task` in this example). Each block type defines
|
|
how many _labels_ must follow the type keyword. The `task` block type
|
|
expects one label, which is `webserver` in the example above.
|
|
A particular block type may have any number of required labels, or it may
|
|
require none as with the nested `config` block type.
|
|
|
|
After the block type keyword and any labels, the block _body_ is delimited
|
|
by the `{` and `}` characters. Within the block body, further arguments
|
|
and blocks may be nested, creating a hierarchy of blocks and their associated
|
|
arguments.
|
|
|
|
HCL uses a limited number of _top-level block types,_ which
|
|
are blocks that can appear outside of any other block in a configuration file.
|
|
|
|
## Identifiers
|
|
|
|
Argument names, block type names, and the names of most Nomad-specific
|
|
constructs like tasks, input variables, etc. are all _identifiers_.
|
|
|
|
Identifiers can contain letters, digits, underscores (`_`), and hyphens (`-`).
|
|
The first character of an identifier must not be a digit, to avoid ambiguity
|
|
with literal numbers.
|
|
|
|
For complete identifier rules, Nomad implements
|
|
[the Unicode identifier syntax](http://unicode.org/reports/tr31/), extended to
|
|
include the ASCII hyphen character `-`.
|
|
|
|
## Comments
|
|
|
|
HCL supports three different syntaxes for comments:
|
|
|
|
- `#` begins a single-line comment, ending at the end of the line.
|
|
- `//` also begins a single-line comment, as an alternative to `#`.
|
|
- `/*` and `*/` are start and end delimiters for a comment that might span
|
|
over multiple lines.
|
|
|
|
The `#` single-line comment style is the default comment style and should be
|
|
used in most cases. Automatic configuration formatting tools may automatically
|
|
transform `//` comments into `#` comments, since the double-slash style is
|
|
not idiomatic.
|
|
|
|
## Character Encoding and Line Endings
|
|
|
|
Nomad configuration files must always be UTF-8 encoded. While the
|
|
delimiters of the language are all ASCII characters, Nomad accepts
|
|
non-ASCII characters in identifiers, comments, and string values.
|
|
|
|
Nomad accepts configuration files with either Unix-style line endings
|
|
(LF only) or Windows-style line endings (CR then LF), but the idiomatic style
|
|
is to use the Unix convention, and so automatic configuration formatting tools
|
|
may automatically transform CRLF endings to LF.
|