cisagov / cisagov/pre-commit-packer

Duplicate local definition or Duplicate variable

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
21
Forks
16
PR merge metrics
No merged PRs in 30d

Description

# 🐛 Summary #

Running `packer_validate` always returns failed. Passing `--verbose` to `pre-commit` doesn't show anything further.

Running Packer v1.11.2
Running pre-commit 4.0.1
Running 0.3.0 of pre-commit-packer
Running on x86 MacOS (latest release)

There are 10 Packer files in the root of the directory.

## To reproduce ##

Steps to reproduce the behavior:

Can run `PACKER_LOG=1 pre-commit run --all-files` and I get an output like this

```bash
Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

on host1.pkr.hcl line 25, in locals:
25: timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

on host3.pkr.hcl line 24, in locals:
24: timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

on host4.pkr.hcl line 24, in locals:
24: timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

on host5.pkr.hcl line 24, in locals:
24: timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

Error: Duplicate local definition

on host6.pkr.hcl line 24, in locals:
24: timestamp = regex_replace(timestamp(), "[- TZ:]", "")

Local variable "timestamp" is defined twice in your templates. Other definition
found at "aws-amz-linux-2023.pkr.hcl:24,15-56"

2025/02/04 15:55:47 [INFO] (telemetry) Finalizing.
2025/02/04 15:55:47 waiting for all plugin processes to complete...
```

## Expected behavior ##

```bash
for file in $(ls |grep pkr.hcl); do packer validate $file; done
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
The configuration is valid.
```

## Any helpful log output or screenshots ##

Paste the results here:

See above I believe.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.