hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

Plugins installed via `packer plugins install` are not loaded when using JSON templates #11696

Closed nywilken closed 2 years ago

nywilken commented 2 years ago

Plugins installed via packer plugins install are not loaded when using JSON templates

Upon installing a plugin via packer plugins install it was found that the plugin is usable for HCL2 template builds. But when running a build on a JSON template for the same plugin Packer results in an error. Since the plugins command can be used for installing external plugins I would expect the plugin to be found regardless of the build template type.

Reproduction Steps

  1. Run packer plugins install github.com/sylviamoss/comment
  2. Run packer build source.json

Build Template: source.json


{
    "builders": [
        {
            "type": "null",
            "communicator": "none"
        }
    ],
    "provisioners": [
        {
          "type": "comment",
          "comment": "Begin",
          "ui": true,
          "bubble_text": true
        },
        {
          "type": "shell-local",
          "inline": ["echo \"This is a shell script\""]
        },
        {
          "type": "comment",
          "comment": "In the middle of Provisioning run",
          "ui": true
        },
        {
          "type": "shell-local",
          "inline": ["echo \"This is another shell script\""]
        },
        {
          "type": "comment",
          "comment": "this comment is invisible and won't go to the UI"
        },
        {
          "type": "comment",
          "comment": "End",
          "ui": true,
          "bubble_text": true
        }
    ]
}

Expected Results

~>  packer build source.json
null: output will be in this color.

==> null:   ____                   _
==> null:  | __ )    ___    __ _  (_)  _ __
==> null:  |  _ \   / _ \  / _` | | | | '_ \
==> null:  | |_) | |  __/ | (_| | | | | | | |
==> null:  |____/   \___|  \__, | |_| |_| |_|
==> null:                  |___/
==> null:
==> null: Running local shell script: /var/folders/vz/rv7bk6v15211jxg8q801f7kw0000gq/T/packer-shell1166603649
    null: This is a shell script
==> null: In the middle of Provisioning run
==> null: Running local shell script: /var/folders/vz/rv7bk6v15211jxg8q801f7kw0000gq/T/packer-shell4281157345
    null: This is another shell script
==> null:   _____               _
==> null:  | ____|  _ __     __| |
==> null:  |  _|   | '_ \   / _` |
==> null:  | |___  | | | | | (_| |
==> null:  |_____| |_| |_|  \__,_|
==> null:
Build 'null' finished after 201 milliseconds 504 microseconds.

==> Wait completed after 201 milliseconds 551 microseconds

==> Builds finished. The artifacts of successful builds are:
--> null: Did not export anything. This is the null builder

Actual Results

~>  packer build source.json
Error: Failed to initialize build "null"

error initializing provisioner 'comment': Unknown provisioner comment

==> Wait completed after 4 microseconds

==> Builds finished but no artifacts were created.
github-actions[bot] commented 2 years ago

I'm going to lock this issue 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 similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.