How to get the version of the plugins shipped with packer?

I have contributed, some months ago, to the packer-plugin-azure project. I am surprised to see that on packer 1.7.7 rpm, available in hashicorp repo, I am still getting the errors on azure-dtl that my patch fixed… but I do not know how to get the version of the plugins shipped with that packer rpm (I am running CentOS).

How can I get that information? Thank you!

Packer has the latest plugin version at the time of the release. You can check which version of the azure plugin is embedded in v1.7.7 by checking its go.mod file in the packer repo: packer/go.mod at v1.7.7 · hashicorp/packer · GitHub
It’s v1.0.4 which is the latest at the time I send this message.

I think I remember merging your fix and if I’m right it’s there packer-plugin-azure/config.go at main · hashicorp/packer-plugin-azure · GitHub. Could you check you don’t have an older binary of the plugin installed in your machine?
If it’s using a local binary, Packer prints out the location and version in the first few lines of logs when building with PACKER_LOG set.

Hi @sylviamoss,

this is the log I am getting in packer.log. I have tried to find any packer-plugin-azure, but found none. I assume that the plugin is embedded on the packer binary itself??

2021/10/29 12:01:39 [INFO] Packer version: 1.7.7 [go1.17.2 linux amd64]
2021/10/29 12:01:39 [ERR] Error loading config directory: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 [TRACE] discovering plugins in /usr/bin
2021/10/29 12:01:39 [ERR] Error loading config directory: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 [TRACE] discovering plugins in .
2021/10/29 12:01:39 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/10/29 12:01:39 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/testuser/.packerconfig
2021/10/29 12:01:39 [WARN] Config file doesn't exist: /home/testuser/.packerconfig
2021/10/29 12:01:39 [WARN] (telemetry) setup error: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 [INFO] Setting cache directory: /home/testuser/tooling/ansible/.cache/packer
2021/10/29 12:01:39 [ERR] Checkpoint setup error: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 [TRACE] validateValue: not active for resource_group, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for client_id, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for subscription_id, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for tenant_id, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for goldenimage_version, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for connected, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for client_secret, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for goldenimage_apps, so skipping
2021/10/29 12:01:39 [TRACE] validateValue: not active for goldenimage_suffix, so skipping
2021/10/29 12:01:39 [TRACE] Starting internal plugin packer-builder-azure-dtl
2021/10/29 12:01:39 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-builder-azure-dtl"}
2021/10/29 12:01:39 Waiting for RPC address for: /usr/bin/packer
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [INFO] Packer version: 1.7.7 [go1.17.2 linux amd64]
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [ERR] Error loading config directory: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/testuser/.packerconfig
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [WARN] Config file doesn't exist: /home/testuser/.packerconfig
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [WARN] (telemetry) setup error: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [INFO] Setting cache directory: /home/testuser/tooling/ansible/.cache/packer
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: args: []string{"packer-builder-azure-dtl"}
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: [ERR] Checkpoint setup error: No $HOME environment variable found, required to set Config Directory
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: Plugin address: unix /tmp/packer-plugin2408260962
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: Waiting for connection...
2021/10/29 12:01:39 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin2408260962
2021/10/29 12:01:39 packer-builder-azure-dtl plugin: Serving a plugin connection...
2021/10/29 12:01:40 ui error: Error: 1 error(s) occurred:

* winrm_username must be specified.

  on packer/golden_image.pkr.hcl line 1:
  (source code not available)

2021/10/29 12:01:40 Build debug mode: false
2021/10/29 12:01:40 Force build: true
2021/10/29 12:01:40 On error:
2021/10/29 12:01:40 Waiting on builds to complete...
2021/10/29 12:01:40 ui:
==> Wait completed after 5 microseconds
2021/10/29 12:01:40 ui:
==> Builds finished but no artifacts were created.
2021/10/29 12:01:40 waiting for all plugin processes to complete...
2021/10/29 12:01:40 /usr/bin/packer: plugin process exited

The error you’re having is not related to the fix you made. You’re actually missing the winrm communicator required configuration. Communicators - Templates | Packer by HashiCorp

But the winrm_username is set by default to ‘packer’, right? why does need to be explicitely set?
Update: and it is not only that: in builder/azure/dtl/config.go, subrutine newConfig, there is a call to setUserNamePassword, that starts like


        if c.Comm.SSHUsername == "" {
                c.Comm.SSHUsername = DefaultUserName
        }

        c.UserName = c.Comm.SSHUsername

This means that in for both windows and linux the value of DefaultUsername will make it to UserName. What I do not know is how to make the declaration of UserName in the struct Config to be not required. I tried with

UserName                string `mapstructure:"winrm_username" required:"false"`

but was unsuccessful.