Commit graph

18745 commits

Author SHA1 Message Date
anshulSharma
902cdf5cb4 doc changes about CRT migration (#13433)
* doc changes about CRT migration

* docs changes suggested

* docs changes suggested

* docs changes suggested

* typo fix

* typo fix
2025-07-29 20:26:45 +05:30
Jenna Goldstrich
a7c85ff35b Make generate creases this SBOM provisioner docs page 2025-07-23 12:15:40 -07:00
Nick Philbrook
2154e44c3e Add note about *just metadata* 2025-07-23 12:15:40 -07:00
nphilbrook
2c5c84e514 Update website/content/docs/templates/hcl_templates/blocks/build/hcp_packer_registry.mdx
Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
2025-07-23 12:15:40 -07:00
Nick Philbrook
9d8b2f03f0 move hcp_packer_registry block out of the build block as per error message with current CLI 2025-07-23 12:15:40 -07:00
Ryan Johnson
a27e911fd8 docs: add conditional expressions
This update adds a new section explaining conditional expressions in HCL, including syntax, usage examples, and best practices for clarity and maintainability. The documentation covers how to use conditionals for default values, dynamic argument omission, and recommends using locals for complex logic.

Ref: #12806

Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
2025-07-23 12:15:40 -07:00
tanmay-hc
79368ee922
Merge pull request #13412 from hashicorp/temp-web
Updated Stable Website
2025-06-12 12:44:23 +05:30
Tanmay Jain
3d7ef0410e Fix 2025-06-12 12:34:32 +05:30
Bart Dorlandt
3137448b67 Fix typo 2025-06-12 12:05:45 +05:30
trujillo-adam
614e35f6ff updated provisioners reference topics 2025-06-12 12:05:01 +05:30
anshulSharma
be536862ae
docs: add upgrade/release notes for 1.13.0 (#13394) (#13400)
* docs: add upgrade/release notes for 1.13.0

* docs: add upgrade/release notes for 1.13.0
2025-06-04 12:30:05 +05:30
Ryan Johnson
15886817b2 docs: update link to vsphere examples
Updated the link for the Packer Examples for VMware vSphere after a repository transfer.

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
2025-05-06 13:25:53 -07:00
Anurag Sharma
8285a3f2ad fix(docs): correct firewall command for WinRM HTTPS setup 2025-05-06 11:47:03 +05:30
Anurag Sharma
94e03ec20b docs: issues when temp is noexec 2025-04-17 12:33:23 +05:30
Tanmay Jain
73de11bc72 Added Documentaion Comments for SSH Tunnel flags 2025-04-09 12:52:53 +05:30
Karthik P
5ecf1a78e8 docs: add installing plugins from a compiled binary example 2025-04-08 15:42:58 -04:00
Tanmay Jain
8d9f0df7ad UPDATE: Added a note for adding forward slash while copying files 2025-03-03 16:54:26 -05:00
Martin Grogan
a38a6513ef docs: add PACKER_GETTER_READ_TIMEOUT in config 2025-03-03 16:54:26 -05:00
Lucas Bajolet
f64ba590db docs: add upgrade/release notes for 1.12.0 2025-01-24 15:27:16 -05:00
Lucas Bajolet
754c622ca3 version: cut release 1.12.0 2025-01-22 10:13:57 -05:00
Lucas Bajolet
f1442be54f CHANGELOG: add changes for v1.12.0 2025-01-22 10:02:39 -05:00
Devashish
2e609231b4 website: add docs for the hcp-sbom provisioner 2025-01-21 16:57:50 -05:00
Jenna Goldstrich
8dcd9fe1a5 Ensure org ID is set and move UploadSbom to api package 2025-01-21 16:57:50 -05:00
Jenna Goldstrich
347c57306c hcp: use enum for HCP SBOM upload
Since the protos for uploading an SBOM for a build have been changed to
use an enumeration instead of a plain string with the latest revisions
to the HCP Packer SBOM support feature, we update how we reference those
values for the SBOM format to use that enum instead.
2025-01-21 16:57:50 -05:00
Lucas Bajolet
619c524afb command: exit non-zero if uploading to HCP failed
In the current state, a Packer build that succeeds but fails to push its
metadata to HCP for reasons other than a lack of artifact will always
succeed from the perspective of a user invoking `packer build`.

This can be a bit misleading, as users may expect their artifacts to
appear on HCP Packer if their build succeeded on Packer Core, so this
commit changes this behaviour, instead reporting HCP errors as a real
error if the build failed, so packer returns a non-zero error code if
this happens.
2025-01-21 16:57:50 -05:00
Lucas Bajolet
9b3f29faf9 hcp: wrap completeBuild to mark as failed on error
When a build cannot be completed without errors, the build state was
left as running, unless the build explicitly failed, which meant that
HCP Packer would be responsible for changing the status after the
heartbeats for the build stopped being sent for two 5m periods.

This commit changes this behaviour, by explicitly marking the build as
failed if something did not work while trying to complete a build on HCP
Packer, even if the local Packer core build succeeded before that.
2025-01-21 16:57:50 -05:00
Jenna Goldstrich
362c547211 hcp: integrate SBOM upload to HCP code
Since packer now supports keeping track of SBOMs produced during a
build, we add the code to integrate those changes into the internal/hcp
package, so we do upload them on build completion.
2025-01-21 16:57:50 -05:00
Lucas Bajolet
a8c9467463 packer_test: add integration tests for hcp-sbom 2025-01-21 16:57:50 -05:00
Devashish
a353260f5d packer: add hcp-sbom provisioner
The hcp-sbom provisioner is a provisioner that acts essentially like a
download-only file provisioner, which also verifies the file downloaded
is a SPDX/CycloneDX JSON-encoded SBOM file, and sets up its upload to
HCP Packer later on.
2025-01-21 16:57:50 -05:00
Lucas Bajolet
56400f27cb packer_test: add gob/pb test suite
With the draft to support both gob and protobuf as serialisation formats
for Packer, along with the SDK changes that propel them, we add a series
of tests that make sure the logic that picks which protocol is solid and
functional.

These tests rely on building several versions of the tester plugin, with
and without protobuf support, to then install them in the tests as
needed to test the logic of Packer using packer build with them, and
templates that require multiple plugins.
2025-01-21 16:44:03 -05:00
Lucas Bajolet
9f6f0ba6a2 packer: pick protobuf/gob for serialisation (#13025)
As we're trying to move away from gob for serialising data over the
wire, this commit adds the capability for Packer to pick dynamically
between gob or protobuf for the serialisation format to communicate with
plugins.

As it stands, if all the plugins discovered are compatible with
protobuf, and we have not forced gob usage, protobuf will be the
serialisation format picked.

If any plugin is not compatible with protobuf, gob will be used for
communicating with all the plugins that will be used over the course of
a command.
2025-01-21 16:44:03 -05:00
Lucas Bajolet
9f3e32b9fc hcl2template: add support for raw aws secrets
As the SDK now supports it in the context of legacy templating engine,
we add support in HCL2 for the aws_secretsmanager_raw function, which
gets the raw value of a secret from aws secrets manager.
2025-01-21 14:39:49 -05:00
Jenna Goldstrich
cf6a82fae8 Make error less brittle to fix upcoming error with HCP SDK Go changing how we return 404 error 2025-01-21 11:33:32 -08:00
Lucas Bajolet
dddc1fb356 go.mod: bump Packer plugin SDK to v0.6.0
Since the version 0.6.0 of the plugin SDK was released yesterday, we
bump packer to use this version.
This change adds new functions to use within Packer regarding AWS
secretsmanager, along with changes to how plugins can communicate
over-the-wire (e.g. using protobuf/msgpack for serialising
configurations instead of gob).
2025-01-21 11:29:53 -05:00
Joban
2ff129cd34 fix(example): make UUIDv4 example RFC compliant
# Description

The output of the example on [uuidv4 Function](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/functions/uuid/uuidv4) is not a valid RFC compliant UUIDv4. It indicates the usage of the `uuidv4()` function and outputs `b5ee72a3-54dd-c4b8-551c-4bdc0204cedb` which is not a valid UUIDv4.

I've corrected the example to output a UUIDv4 conforming to the RFC as such `xxxxxxxx-xxxx-4xxx-Nxxx-xxxxxxxxxxxx`, where:

- The 13th character is always `4` (indicating version 4).
- The 17th character must be either `8`, `9`, `a`, or `b` (indicating the first character of the variant).

# Changes

```diff
- b5ee72a3-54dd-c4b8-551c-4bdc0204cedb
+ 9fc99a70-7cd5-482d-bb2b-03af016e4e94
```

Replaces the old UUID output with a valid RFC compliant UUIDv4.

# References

- [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122)
- [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562)

# Misc.

To make sure this wasn't an issue with the `uuidv4()` function within Hashicorp's [packer](https://github.com/hashicorp/packer) I tested the function in the following way:

### Command executed:

```ps
> .\packer.exe inspect .\uuid.pkr.hcl
```

### Contents of the _uuid.pkr.hcl_ file:

```hcl
locals {
  uuid_0 = uuidv4()
  uuid_1 = uuidv4()
  uuid_2 = uuidv4()
  uuid_3 = uuidv4()
  uuid_4 = uuidv4()
  uuid_5 = uuidv4()
  uuid_6 = uuidv4()
  uuid_7 = uuidv4()
  uuid_8 = uuidv4()
  uuid_9 = uuidv4()
}
```

### Output:

```ps
Packer Inspect: HCL2 mode

> input-variables:


> local-variables:

local.uuid_0: "90877db8-5519-46ea-ae15-7dfb92594064"
local.uuid_1: "fe6a4649-97d9-4686-b981-3295175f941a"
local.uuid_2: "9944d83d-dab2-4cfb-a1db-572d19271e7a"
local.uuid_3: "547cddb7-c979-4b87-90d0-2bd9b68858b5"
local.uuid_4: "c13dc47a-552c-4dfb-a75d-2f63bb248b41"
local.uuid_5: "3db1ce29-bdde-4642-b010-1a41d47c22a3"
local.uuid_6: "4a020460-edd1-471d-b8a2-5956c0c68257"
local.uuid_7: "1845bf87-6908-4fc0-8f11-b5b4f36c60a7"
local.uuid_8: "f5c7e552-b799-45f3-8172-46162eadfd89"
local.uuid_9: "057c2eaf-6769-4a8d-90c8-775aec80496a"

> builds:
```
2025-01-21 10:13:57 -05:00
Martin Grogan
cb4965d53a hcl2template: add anytrue function
this function add the hcl2 anytrue function which takes a collection and
return true if any of the element is true.
2025-01-21 10:07:10 -05:00
Martin Grogan
476ddc3810 hcl2template: add alltrue function
add an hcl2 function that return true if all the value in a collection
are true, this function was derived from terraform codebase
2025-01-21 10:07:10 -05:00
Gustavo Cruz
7f64ca11f6 fix: packer validate unsupported type error
`packer validate` would output the same error message four times per
unsupported root block type found in a template (e.g., 'src' instead of
'source'). This behavior was due to a function being called four times
for each file on each stage of the parsing.
2025-01-21 10:06:45 -05:00
dependabot[bot]
3826a94758 build(deps): bump golang.org/x/net in /packer_test/common/plugin_tester
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.33.0.
- [Commits](https://github.com/golang/net/compare/v0.23.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-21 09:49:43 -05:00
dependabot[bot]
8b2a3ccdf3 build(deps): bump github.com/hashicorp/hcp-sdk-go
Bumps [github.com/hashicorp/hcp-sdk-go](https://github.com/hashicorp/hcp-sdk-go) from 0.112.0 to 0.131.0.
- [Release notes](https://github.com/hashicorp/hcp-sdk-go/releases)
- [Changelog](https://github.com/hashicorp/hcp-sdk-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/hcp-sdk-go/compare/v0.112.0...v0.131.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/hcp-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-21 09:49:04 -05:00
hashicorp-tsccr[bot]
ea9d02d596 Result of tsccr-helper -log-level=info gha update .github/ 2025-01-20 17:25:44 -05:00
Lucas Bajolet
f24c978d46 go.mod: bump go-git to v5.13.0
Version 5.11.0 of the go-git library is vulnerable to two CVEs as
reported by our scanners.

Both are not impacting Packer since we only use go-git to read values
from a local Git repository, but still we upgrade our version to 5.13.0
so those reports don't apply to us.
2025-01-06 15:48:15 -05:00
Lucas Bajolet
783d5113ba release: ignore AWS SDK vulnerability for release
The reported AWS S3 vulnerability was inherited from the go-getter
module that Packer uses for downloading files from external sources.

This vulnerability only impacts S3 uploads, therefore Packer is not
vulnerable itself as go-getter only downloads such blobs.

Since the change required to fix this advisory would be to bump the AWS
SDK to v2, this being a major change, is not something to do lightly, so
we opted to ignore this advisory for now so it doesn't block upcoming
releases.
2025-01-06 15:12:19 -05:00
Martin Grogan
024bf7259a docs: make TMPDIR clickable
The option is less visible than the other one and by adding the quote,
it creates an anchor that will make it easier to link.
2024-12-23 15:18:33 -05:00
Lucas Bajolet
77bf0282a7 go.mod: bump golang.org/x/net to v0.33.0
The version of golang.org/x/net that we're using (v0.25.0) is vulnerable
to GO-2024-3333, a DoS vulnerability.
Packer is not particularly vulnerable to this, as we are not a hosted
service, but since security scanners report this, and the fix is rather
simple, we address it today.
2024-12-20 13:47:18 -05:00
dependabot[bot]
38f081c9ed build(deps): bump golang.org/x/crypto
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.31.0.
- [Commits](https://github.com/golang/crypto/compare/v0.21.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-20 11:11:20 -05:00
Martin Grogan
5940ab6d64 docs: put hcl2 example in first tab 2024-12-20 10:39:32 -05:00
Lucas Bajolet
b6141fd532 command: copy AWS plugin structures for upgrade
The hcl2_upgrade command transforms a JSON template into an HCL2
template for use with Packer.

The command is quite fragile already, but given that this is the last
remaining fragment that causes Packer to depend on the AWS SDK directly,
we can do away with it.

This commit therefore imports the definitions for AWS access config, so
we can extract this information from the JSON template, and include it
in the definition of the output source for AWS, since we manage this one
differently from other sources.

This allows us to not depend on the AWS plugin directly, which in turn
makes Packer not need to link with the AWS plugin when compiling the
executable.
We are still depending on the AWS SDK for now since the SDK exposes a
aws_secretsmanager function that can be used for interpolation (legacy
JSON interpolation to be clear), so this cannot be removed from now, but
we should consider some form of remediation in the future.
2024-12-17 17:42:58 -05:00
Lucas Bajolet
cd009b0f3b go.mod: bump x/crypto to v0.31.0
The crypto experimental module that the SDK depends on was detected
vulnerable on v0.23.0 to an authentication bypass attack through the
ServerConfig for SSH.

This is only used for locally proxying SSH communications, typically for
use with Ansible to provide an SSH server with which to interact, in
order to provision an instance of an OS that uses a communicator other
than SSH, therefore the vulnerability does not necessarily impact us.
However, in order to resolve the automatic report of that vulnerability,
we bump the crypto module's version to 0.31.0, where that problem was
addressed.
2024-12-17 14:06:59 -05:00
Lucas Bajolet
5ff0f146c6 packer_test: introduce global compilation queue
Compiling plugins was originally intended to be an idempotent operation.
This however starts to change as we introduce build customisations,
which have the unfortunate side-effect of changing the state of the
plugin directory, leading to conflicts between concurrent compilation
jobs.

Therefore to mitigate this problem, this commit changes how compilation
jobs are processed, by introducing a global compilation queue, and
processing plugins' compilation one-by-one from this queue.

This however makes such requests asynchronous, so test suites that
require plugins to be compiled will now have to wait on their completion
before they can start their tests.

To this effect, we introduce one more convenience function that
processes those errors, and automatically fails the test should one
compilation job fail for any reason.
2024-12-17 10:45:33 -05:00