Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packer: link to docs if a component is missing #12705

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

lbajolet-hashicorp
Copy link
Contributor

When a user invokes packer for a build or validation, the template being processed needs components to be present for Packer to process it without error.

If the component cannot be found from the plugins loaded (or from the components bundled with Packer), Packer errors, and the command fails.

This is expected, but the error message does not suggest anything to fix the error, potantially leaving users confused at the problem.

This commit suggests either a replacement (in case of a typo), or points to the web documentation for Packer, specifically the integrations, so they can look for the plugin they're missing, and install it, so subsequent invocations of Packer work.

@lbajolet-hashicorp lbajolet-hashicorp marked this pull request as ready for review November 22, 2023 20:02
@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner November 22, 2023 20:02
Copy link
Contributor

@JenGoldstrich JenGoldstrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could add some unit test coverage but otherwise looks good!

@@ -218,15 +219,33 @@ func (c *Core) BuildNames(only, except []string) []string {
func (c *Core) generateCoreBuildProvisioner(rawP *template.Provisioner, rawName string) (CoreBuildProvisioner, error) {
// Get the provisioner
cbp := CoreBuildProvisioner{}

if !c.components.PluginConfig.Provisioners.Has(rawP.Type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth updating the core build tests in packer/core_test.go for this change, but I didn't dig into these tests too much to see how practical that is

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Nicely done on the quick turnaround.

I think the output needs a little formatting

~>  packer validate ansible_docker.json
Error: Failed to initialize build "docker"

The builder docker is unknown by Packer, and is likely part of a plugin that is
not installed.
You may find the plugin needed in the Packer integrations, and install it as
documented there:
https://developer.hashicorp.com/packer/integrations?filter=docker
~>  packer validate ansible_ssh_no_proxy_ssm.pkr.hcl
Error: Unknown source type amazon-ebs

  on ansible_ssh_no_proxy_ssm.pkr.hcl line 29:
  (source code not available)

The source amazon-ebs is unknown by Packer, and is likely part of a plugin that
is not installed.
You may find the plugin needed in the Packer integrations, and install it as
documented there:
https://developer.hashicorp.com/packer/integrations?filter=amazon

Error: Unknown provisioner type "ansible"

  on ansible_ssh_no_proxy_ssm.pkr.hcl line 32:
  (source code not available)

The provisioner ansible is unknown by Packer, and is likely part of a plugin
that is not installed.
You may find the plugin needed in the Packer integrations, and install it as
documented there:
https://developer.hashicorp.com/packer/integrations?filter=ansible
~>  packer build qemu_fedora_compress_googlecompute-import_post-processor.pkr.hcl
Error: Unknown source type qemu

  on qemu_fedora_compress_googlecompute-import_post-processor.pkr.hcl line 39:
  (source code not available)

The source qemu is unknown by Packer, and is likely part of a plugin that is not
installed.
You may find the plugin needed in the Packer integrations, and install it as
documented there:
https://developer.hashicorp.com/packer/integrations?filter=qemu

Error: Unknown post-processor type "googlecompute-import"

  on qemu_fedora_compress_googlecompute-import_post-processor.pkr.hcl line 46:
  (source code not available)

The post-processor googlecompute-import is unknown by Packer, and is likely part
of a plugin that is not installed.
You may find the plugin needed in the Packer integrations, and install it as
documented there:
https://developer.hashicorp.com/packer/integrations?filter=googlecompute

hcl2template/plugin.go Show resolved Hide resolved
@nywilken nywilken added enhancement backport/1.10.x Backport PR changes to `release/1.10.x` labels Nov 22, 2023
When a user invokes packer for a build or validation, the template being
processed needs components to be present for Packer to process it
without error.

If the component cannot be found from the plugins loaded (or from the
components bundled with Packer), Packer errors, and the command fails.

This is expected, but the error message does not suggest anything to fix
the error, potantially leaving users confused at the problem.

This commit suggests either a replacement (in case of a typo), or points
to the web documentation for Packer, specifically the integrations, so
they can look for the plugin they're missing, and install it, so
subsequent invocations of Packer work.
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lbajolet-hashicorp lbajolet-hashicorp merged commit efe182b into main Nov 22, 2023
11 checks passed
@lbajolet-hashicorp lbajolet-hashicorp deleted the missing_plugins_hint_on_error branch November 22, 2023 21:29
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/1.10.x Backport PR changes to `release/1.10.x` enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants