### Install Levant using Go Source: https://github.com/hashicorp/levant/blob/main/README.md This command installs the Levant binary using the Go toolkit. It fetches the repository from GitHub and then installs the executable into your Go binary path. ```Shell go get github.com/hashicorp/levant && go install github.com/hashicorp/levant ``` -------------------------------- ### Nomad Job Template with YAML Variable Substitution Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md This HCL snippet presents a Nomad job template using Levant's `[[ ]]` syntax for variable substitution, compatible with YAML variable files. It demonstrates dynamic configuration of resources (CPU, memory, network) similar to the JSON example. ```hcl resources { cpu = [[.resources.cpu]] memory = [[.resources.memory]] network { mbits = [[.resources.network.mbits]] } } ``` -------------------------------- ### Get Current ISO_8601 Timestamp (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the current ISO_8601 standard timestamp as a string. The timestamp is in the timezone of the machine where the rendering process is executed. Rendered Output (example): ``` 2018-06-25T09:45:08+02:00 ``` ```Levant Template [[ timeNow ]] ``` -------------------------------- ### Parse String to Boolean (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Parses a given string as a boolean value, useful for conditional checks. The example shows how to use it to conditionally add tags based on a 'true' string value. Rendered Output: ``` beta-release ``` ```Levant Template [[ if "true" | parseBool ]][[ "beta-release" ]][[ end ]] ``` -------------------------------- ### Get Current UTC ISO_8601 Timestamp (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the current ISO_8601 standard timestamp as a string, specifically in Coordinated Universal Time (UTC). Rendered Output (example): ``` 2018-06-25T07:45:08Z ``` ```Levant Template [[ timeNowUTC ]] ``` -------------------------------- ### Pull Levant Docker Image Source: https://github.com/hashicorp/levant/blob/main/README.md This command pulls the latest official Levant Docker image from Docker Hub. This allows users to run Levant within a containerized environment without needing to install it directly on their system. ```Shell docker pull hashicorp/levant ``` -------------------------------- ### Get Current ISO_8601 Timestamp in Specific Timezone (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the current ISO_8601 standard timestamp as a string for a specified timezone. The timezone must conform to the IANA Time Zone database entries, such as 'ASIA/SEOUL'. Rendered Output (example): ``` 2018-06-25T16:45:08+09:00 ``` ```Levant Template [[ timeNowTimezone "ASIA/SEOUL" ]] ``` -------------------------------- ### Access Global Variables in Levant Template Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Demonstrates how to define and access global variables within a Levant template, including scalar values and array iteration. The example shows accessing a global integer and iterating through a global array, combining values. Rendered Output: ``` 1 a1,b1,c1, ``` ```YAML my_i32: 1 my_array: - "a" - "b" - "c" my_nested: my_data1: "lorempium" my_data2: "faker" ``` ```Levant Template [[ $.my_i32 ]] [[ range $c := $.my_array ]][[ $c ]]-[[ $.my_i32 ]],[[ end ]] ``` -------------------------------- ### Build Levant from Source Source: https://github.com/hashicorp/levant/blob/main/README.md These commands clone the Levant repository from GitHub and then build the binary using the `make dev` command. The resulting executable will be available in the `./bin/levant` directory within the cloned repository. ```Shell git clone git://github.com/hashicorp/levant.git make dev ``` -------------------------------- ### Levant `deploy` Command Source: https://github.com/hashicorp/levant/blob/main/docs/commands.md The `deploy` command is the main entry point for Levant to deploy a Nomad job. It supports various flags to configure the deployment process, including Nomad API address, canary promotion settings, variable file handling, and logging options. Levant also supports autoloading `levant.[yaml,yml,tf]` and `*.nomad` files from the current working directory. ```APIDOC Command: deploy Description: Main entry point for deploying Nomad jobs. Flags: -address (string, default: "http://localhost:4646"): The HTTP API endpoint for Nomad where all calls will be made. -allow-stale (bool, default: false): Allow stale consistency mode for requests into nomad. -canary-auto-promote (int, default: 0): The time period in seconds that Levant should wait for before attempting to promote a canary deployment. -consul-address (string, default: "localhost:8500"): The Consul host and port to use when making Consul KeyValue lookups for template rendering. -force (bool, default: false): Execute deployment even though there were no changes. -force-batch (bool, default: false): Forces a new instance of the periodic job. A new instance will be created even if it violates the job's prohibit_overlap settings. -force-count (bool, default: false): Use the taskgroup count from the Nomad job file instead of the count that is obtained from the running job count. -ignore-no-changes (bool, default: false): By default if no changes are detected when running a deployment Levant will exit with a status 1 to indicate a deployment didn't happen. This behaviour can be changed using this flag so that Levant will exit cleanly ensuring CD pipelines don't fail when no changes are detected. -log-level (string, default: "INFO", valid values: DEBUG, INFO, WARN, ERROR, FATAL): The level at which Levant will log to. -log-format (string, default: "HUMAN", valid values: HUMAN, JSON): Specify the format of Levant's logs. -var-file (string, default: ""): The variables file to render the template with. This flag can be specified multiple times to supply multiple variables files. Variables: -var 'key=value': Pass individual variables on the command line. Multiple commands can be passed in this format. Variables passed via the command line take precedence over the same variable declared within a passed variable file. Autoloading: Levant will look in the current working directory for a 'levant.[yaml,yml,tf]' file and a single '*.nomad' file to use for the command actions. ``` ```Shell levant deploy -log-level=debug -address=nomad.devoops -var-file=var.yaml -var 'var=test' example.nomad ``` -------------------------------- ### Levant Plan Command for Nomad Job Deployments Source: https://github.com/hashicorp/levant/blob/main/docs/commands.md The `plan` command allows users to perform a Nomad plan on a rendered template job, showing expected changes before deployment. It supports various options for Nomad API interaction, Consul integration, variable file usage, and logging. Variables can also be passed individually on the command line, taking precedence over file-declared variables. ```APIDOC -address (string: "http://localhost:4646"): The HTTP API endpoint for Nomad where all calls will be made. -allow-stale (bool: false): Allow stale consistency mode for requests into nomad. -consul-address (string: "localhost:8500"): The Consul host and port to use when making Consul KeyValue lookups for template rendering. -force-count (bool: false): Use the taskgroup count from the Nomad job file instead of the count that is obtained from the running job count. -ignore-no-changes (bool: false): By default if no changes are detected when running a deployment Levant will exit with a status 1 to indicate a deployment didn't happen. This behaviour can be changed using this flag so that Levant will exit cleanly ensuring CD pipelines don't fail when no changes are detected. -log-level (string: "INFO"): The level at which Levant will log to. Valid values are DEBUG, INFO, WARN, ERROR and FATAL. -log-format (string: "HUMAN"): Specify the format of Levant's logs. Valid values are HUMAN or JSON. -var-file (string: ""): The variables file to render the template with. This flag can be specified multiple times to supply multiple variables files. -var 'key=value': Pass variables individually on the command line. Multiple commands can be passed in this format. Variables passed via the command line take precedence over variable files. ``` ```Shell levant plan -log-level=debug -address=nomad.devoops -var-file=var.yaml -var 'var=test' example.nomad ``` -------------------------------- ### Define and Use Local Variables (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Illustrates how to define and use local variables within a Levant template using the `with` keyword. This allows for cleaner access to nested data structures and and improves template readability. Rendered Output: ``` ENV_x1=lorempium ENV_x2=faker ``` ```Levant Template [[ with $data := $.my_nested ]] ENV_x1=[[ $data.my_data1 ]] ENV_x2=[[ $data.my_data2 ]] [[ end ]] ``` -------------------------------- ### Levant Template Function: consulKey Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Demonstrates the `consulKey` function, which queries Consul for the value at a given key path and directly renders it into the template. This allows dynamic retrieval of configuration values from Consul's Key-Value store. ```levant-template [[ consulKey "service/config/cpu" ]] ``` ```text 250 ``` -------------------------------- ### Download Older Levant Binary with Curl Source: https://github.com/hashicorp/levant/blob/main/README.md This command downloads a specific older version of the Levant binary (e.g., 0.2.9) directly from GitHub releases using `curl`. This method was used for versions released prior to the migration to the HashiCorp organization. ```Shell curl -L https://github.com/hashicorp/levant/releases/download/0.2.9/linux-amd64-levant -o levant ``` -------------------------------- ### Levant Render Command for Nomad Job Templates Source: https://github.com/hashicorp/levant/blob/main/docs/commands.md The `render` command allows rendering of a Nomad job template without deploying it, useful for testing or debugging. Levant also supports autoloading files, looking for `levant.[yaml,yml,tf]` and `*.nomad` files in the current working directory. Similar to `deploy`, it supports passing variables individually on the command line, which take precedence over variable files. ```APIDOC -consul-address (string: "localhost:8500"): The Consul host and port to use when making Consul KeyValue lookups for template rendering. -log-level (string: "DEBUG"): The level at which Levant will log to. Valid values are DEBUG, INFO, WARN, ERROR and FATAL. -log-format (string: "JSON"): Specify the format of Levant's logs. Valid values are HUMAN or JSON. -var-file (string: ""): The variables file to render the template with. This flag can be specified multiple times to supply multiple variables files. -out (string: ""): The path to write the rendered template to. The template will be rendered to stdout if this is not set. -var 'key=value': Pass variables individually on the command line. Multiple vars can be passed in this format. Variables passed via the command line take precedence over the same variable declared within a passed variable file. ``` ```Shell levant render -var-file=var.yaml -var 'var=test' example.nomad ``` -------------------------------- ### Loop with Single Integer Input (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Demonstrates the `loop` function when given a single integer. It iterates from 0 up to (but not including) the specified integer. Rendered Output: ``` this-is-output0 this-is-output1 this-is-output2 ``` ```Levant Template [[ range $i := loop 3 ]] this-is-loop[[ $i ]][[ end ]] ``` -------------------------------- ### Nomad Job Template with JSON Variable Substitution Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md This HCL snippet demonstrates a Nomad job template configured to use Levant's `[[ ]]` syntax for variable substitution. It's designed to dynamically inject resource values (CPU, memory, network) from a corresponding JSON variable file, ensuring flexible deployment configurations. ```hcl resources { cpu = [[.resources.cpu]] memory = [[.resources.memory]] network { mbits = [[.resources.network.mbits]] } } ``` -------------------------------- ### Parse String to JSON Object (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Parses a given input string as a JSON object, allowing access to its fields within the template. This enables dynamic template rendering using variables pulled from sources like Consul KV, assuming the KV stores valid JSON. Rendered Output: ``` resources { cpu = 250 memory = 512 network { mbits = 10 } } ``` ```Levant Template [[ with $data := consulKey "service/config/variables" | parseJSON ]] resources { cpu = [[.resources.cpu]] memory = [[.resources.memory]] network { mbits = [[.resources.network.mbits]] } } [[ end ]] ``` -------------------------------- ### Consul Client Environment Variable Configuration Source: https://github.com/hashicorp/levant/blob/main/docs/clients.md Details the environment variables used to configure the Consul API client within Levant, allowing for custom settings such as TLS authentication, HTTP address, and ACL token. ```APIDOC Consul Client Configuration: CONSUL_CACERT: Path to a CA file to use for TLS when communicating with Consul. CONSUL_CAPATH: Path to a directory of CA certificates to use for TLS when communicating with Consul. CONSUL_CLIENT_CERT: Path to a client cert file to use for TLS when 'verify_incoming' is enabled. CONSUL_CLIENT_KEY: Path to a client key file to use for TLS when 'verify_incoming' is enabled. CONSUL_HTTP_ADDR: The `address` and port of the Consul HTTP agent. The value can be an IP address or DNS address, but it must also include the port. CONSUL_TLS_SERVER_NAME: The server name to use as the SNI host when connecting via TLS. CONSUL_HTTP_TOKEN: ACL token to use in the request. If unspecified, the query will default to the token of the Consul agent at the HTTP address. ``` -------------------------------- ### Loop with Two Integer Inputs (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Illustrates the `loop` function when provided with two integers. It iterates from the first integer up to (but not including) the second integer. Rendered Output: ``` this-is-output3 this-is-output4 this-is-output5 ``` ```Levant Template [[ range $i := loop 3 6 ]] this-is-loop[[ $i ]][[ end ]] ``` -------------------------------- ### Levant Template Function: env Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Demonstrates the `env` function, which returns the value of a specified environment variable. It also illustrates how to combine it with the `or` function to provide a default value if the environment variable is not set, enhancing template flexibility. ```levant-template [[ env "HOME" ]] ``` ```levant-template [[ or (env "NON_EXISTENT") "foo" ]] ``` ```text /bin/bash ``` ```text foo ``` -------------------------------- ### Nomad Client Environment Variable Configuration Source: https://github.com/hashicorp/levant/blob/main/docs/clients.md Details the environment variables used to configure the Nomad API client within Levant, allowing for custom settings such as server address, region, namespace, and TLS/ACL authentication parameters. ```APIDOC Nomad Client Configuration: NOMAD_ADDR: The address of the Nomad server. NOMAD_REGION: The region of the Nomad servers to forward commands to. NOMAD_NAMESPACE: The target namespace for queries and actions bound to a namespace. NOMAD_CACERT: Path to a PEM encoded CA cert file to use to verify the Nomad server SSL certificate. NOMAD_CAPATH: Path to a directory of PEM encoded CA cert files to verify the Nomad server SSL certificate. NOMAD_CLIENT_CERT: Path to a PEM encoded client certificate for TLS authentication to the Nomad server. NOMAD_CLIENT_KEY: Path to an unencrypted PEM encoded private key matching the client certificate from `NOMAD_CLIENT_CERT`. NOMAD_SKIP_VERIFY: Do not verify TLS certificate. NOMAD_TOKEN: The SecretID of an ACL token to use to authenticate API requests with. ``` -------------------------------- ### Convert String to Uppercase (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Converts the input string to its uppercase equivalent. Useful for standardizing string values. Rendered Output: ``` QUEUE-NAME ``` ```Levant Template [[ "queue-name" | toUpper ]] ``` -------------------------------- ### Levant `dispatch` Command Source: https://github.com/hashicorp/levant/blob/main/docs/commands.md The `dispatch` command allows you to dispatch an instance of a Nomad parameterized job. It utilizes Levant's advanced job checking features to ensure the job reaches the correct running state. This command supports flags for Nomad API address, logging configuration, and injecting metadata into the job. ```APIDOC Command: dispatch Description: Dispatches an instance of a Nomad parameterized job and utilizes Levant's advanced job checking features to ensure the job reaches the correct running state. Flags: -address (string, default: "http://localhost:4646"): The HTTP API endpoint for Nomad where all calls will be made. -log-level (string, default: "INFO", valid values: DEBUG, INFO, WARN, ERROR, FATAL): The level at which Levant will log to. -log-format (string, default: "HUMAN", valid values: HUMAN, JSON): Specify the format of Levant's logs. -meta (string, default: "key=value"): The metadata key will be merged into the job's metadata. The job may define a default value for the key which is overridden when dispatching. The flag can be provided more than once to inject multiple metadata key/value pairs. Arbitrary keys are not allowed; the parameterized job must allow the key to be merged. Payload: stdin or file path: The command also supports the ability to send data payload to the dispatched instance. This can be provided via stdin by using "-" for the input source or by specifying a path to a file. ``` ```Shell levant dispatch -log-level=debug -address=nomad.devoops -meta key=value dispatch_job payload_item ``` -------------------------------- ### Convert String to Lowercase (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Converts the input string to its lowercase equivalent. Useful for standardizing string values. Rendered Output: ``` queue-name ``` ```Levant Template [[ "QUEUE-NAME" | toLower ]] ``` -------------------------------- ### Terraform Variable File for Levant Templates Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md This Terraform (.tf) file defines variables for use with Levant's templating engine. It uses standard Terraform `variable` blocks, including descriptions, types, and default values, providing a structured and self-documenting way to manage template inputs. ```hcl variable "resources_cpu" { description = "the CPU in MHz to allocate to the task group" type = "string" default = 250 } variable "resources_memory" { description = "the memory in MB to allocate to the task group" type = "string" default = 512 } variable "resources_network_mbits" { description = "the network bandwidth in MBits to allocate" type = "string" default = 10 } ``` -------------------------------- ### YAML Variable File for Levant Templates Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md This YAML file defines the hierarchical variables used by Levant's templating engine. It provides structured values for CPU, memory, and network mbits in a human-readable format, serving as configuration inputs for Nomad job templates. ```yaml --- resources: cpu: 250 memory: 512 network: mbits: 10 ``` -------------------------------- ### Levant Template Function: fileContents Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Illustrates the `fileContents` function, which reads the entire content of a specified file and embeds it directly into the template. This enables the inclusion of external configuration files or arbitrary data within the Nomad job definition. ```yaml --- yaml: - is: everywhere ``` ```levant-template [[ fileContents "/etc/myapp/config" ]] ``` ```yaml --- yaml: - is: everywhere ``` -------------------------------- ### Calculate Modulo (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the modulo of the second value from the first. Rendered Output: ``` 1 ``` ```Levant Template [[ modulo 2 5 ]] ``` -------------------------------- ### JSON Variable File for Levant Templates Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md This JSON file defines the hierarchical variables used by Levant's templating engine. It provides structured values for CPU, memory, and network mbits, allowing for clear and organized configuration inputs for Nomad job templates. ```json { "resources":{ "cpu":250, "memory":512, "network":{ "mbits":10 } } } ``` -------------------------------- ### Levant Template Function: consulKeyOrDefault Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Shows the `consulKeyOrDefault` function, which retrieves a value from Consul KV or uses a specified default if the key does not exist. This is highly useful for providing fallback values for configurations, such as a database address, ensuring robustness. ```levant-template [[ consulKeyOrDefault "service/config/database-addr" "localhost:3306" ]] ``` ```text localhost:3306 ``` -------------------------------- ### Nomad Job Template with Terraform Variable Substitution Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md This HCL snippet shows a Nomad job template utilizing Levant's `[[ ]]` syntax for variable substitution, specifically tailored for Terraform variable files. Note the flat variable naming convention (`resources_cpu`) which differs from JSON/YAML's nested structure. ```hcl resources { cpu = [[.resources_cpu]] memory = [[.resources_memory]] network { mbits = [[.resources_network_mbits]] } } ``` -------------------------------- ### Levant Template Function: consulKeyExists Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Illustrates the `consulKeyExists` function, which checks for the presence of a key in Consul. This function is crucial for implementing conditional logic within templates, enabling sections of the job file to be included or excluded based on Consul KV existence. ```go-template {{ if consulKeyExists "service/config/alerting" }} {{ else }} {{ end }} ``` -------------------------------- ### Add Two Numbers (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the sum of the two passed values. Rendered Output: ``` 7 ``` ```Levant Template [[ add 5 2 ]] ``` -------------------------------- ### Multiply Two Numbers (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the product of the two values. Rendered Output: ``` 16 ``` ```Levant Template [[ multiply 4 4 ]] ``` -------------------------------- ### Levant Scale-In Command for Nomad Job Task Groups Source: https://github.com/hashicorp/levant/blob/main/docs/commands.md The `scale-in` command allows operators to scale a Nomad job and optional task-group down in number. This is particularly helpful for development, testing, or resizing. Scaling can be specified by a fixed count or a percentage, with counts rounded up for percentages to ensure required capacity. ```APIDOC -address (string: "http://localhost:4646"): The HTTP API endpoint for Nomad where all calls will be made. -count (int: 0): The count by which the job and task groups should be scaled in by. Only one of count or percent can be passed. -log-level (string: "INFO"): The level at which Levant will log to. Valid values are DEBUG, INFO, WARN, ERROR and FATAL. -log-format (string: "HUMAN"): Specify the format of Levant's logs. Valid values are HUMAN or JSON. -percent (int: 0): A percentage value by which the job and task groups should be scaled in by. Counts will be rounded up, to ensure required capacity is met. Only one of count or percent can be passed. -task-group (string: ""): The name of the task group you wish to target for scaling. If this is not specified, all task groups within the job will be scaled. ``` ```Shell levant scale-in -count 3 -task-group cache example ``` -------------------------------- ### Parse String to Integer (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Parses a given string as a base-10 int64. This function is often combined with other helpers like `loop` to process numerical values obtained from external sources, such as Consul KV. Rendered Output: ``` conn-pool-id-0 conn-pool-id-1 conn-pool-id-2 ``` ```Levant Template [[ with $i := consulKey "service/config/conn_pool" | parseInt ]][[ range $d := loop $i ]] conn-pool-id-[[ $d ]][[ end ]][[ end ]] ``` -------------------------------- ### Parse String to Unsigned Integer (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Parses a given string as a base-10 unsigned integer (int64). Similar to `parseInt` but for non-negative values. Rendered Output: ``` 100 ``` ```Levant Template [[ "100" | parseUint ]] ``` -------------------------------- ### Levant CLI: Scale Nomad Job Instances Source: https://github.com/hashicorp/levant/blob/main/docs/commands.md The `scale-out` command in Levant allows operators to adjust the number of instances for a Nomad job or specific task group. It supports scaling by a fixed count or a percentage, useful for development, testing, and resizing operations. Only one of `-count` or `-percent` can be used. ```APIDOC Command: scale-out -address (string): The HTTP API endpoint for Nomad where all calls will be made (default: "http://localhost:4646"). -count (int): The count by which the job and task groups should be scaled out by. Only one of count or percent can be passed. -log-level (string): The level at which Levant will log to. Valid values are DEBUG, INFO, WARNING, ERROR and FATAL (default: "INFO"). -log-format (string): Specify the format of Levant's logs. Valid values are HUMAN or JSON (default: "HUMAN"). -percent (int): A percentage value by which the job and task groups should be scaled out by. Counts will be rounded up, to ensure required capacity is met. Only one of count or percent can be passed. -task-group (string): The name of the task group you wish to target for scaling. If this is not specified, all task groups within the job will be scaled. ``` ```CLI levant scale-out -percent 30 -task-group cache example ``` -------------------------------- ### Divide Two Numbers (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the division of the second value from the first. Rendered Output: ``` 3 ``` ```Levant Template [[ divide 2 6 ]] ``` -------------------------------- ### Join Array Elements with Delimiter (Sprig Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Uses the Sprig `join` function (or `sprigJoin` as shown) to concatenate elements of an array into a single string, using a specified delimiter. This is useful for formatting lists into a compact string. Rendered Output: ``` a-b-c ``` ```Levant Template [[ $.my_array | sprigJoin `-` ]] ``` -------------------------------- ### Subtract Two Numbers (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Returns the difference of the second value from the first. Rendered Output: ``` 3 ``` ```Levant Template [[ subtract 2 5 ]] ``` -------------------------------- ### Parse String to Float (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Converts a string representation of a number into a base-10 float64. This is useful for numerical operations within templates. Rendered Output: ``` 3.14159265359 ``` ```Levant Template [[ "3.14159265359" | parseFloat ]] ``` -------------------------------- ### Replace Substring in String (Levant Template) Source: https://github.com/hashicorp/levant/blob/main/docs/templates.md Replaces all occurrences of a specified search string with a replacement string within the input. Useful for string manipulation. Rendered Output: ``` Batman and Catwoman ``` ```Levant Template [[ "Batman and Robin" | replace "Robin" "Catwoman" ]] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.