Skip to content

googlecompute builder does not store {{.WinRMPassword}} in Packer 1.5.0 onwards #8880

@tmmruk

Description

@tmmruk

Overview of the Issue

When using the googlecompute builder in packer 1.5.4 the {{.WinRMPassword}} does not contain any data in the provisioners stages. This cases an issue when trying to execute ansible-playbook from a shell-local provisioner as you don't know what the WinRM password has been set too.

This problem does not happen older versions of packer e.g. 1.4.5.

Reproduction Steps

Run packer build template.json

template.json contains the following:

{
    "builders": [
      {
        "type": "googlecompute",
        "account_file": "account.json",
        "project_id": "packer-gcp",
        "source_image": "windows-server-2019-dc-v20200211",
        "communicator": "winrm",
        "disk_size": "50",
        "winrm_username": "packer_user",
        "winrm_insecure": true,
        "winrm_use_ssl": true,
        "ssh_username": "packer",
        "zone": "europe-west2-a",
        "metadata": {
            "windows-startup-script-cmd": "winrm set winrm/config/service/auth @{Basic=\"true\"}"
        }
      }
    ],
    "provisioners": [
        {
            "type": "shell-local",
            "command": "echo {{.WinRMPassword}}"
        }
    ]
  }

The shell output for WinRMPassword will be blank in packer 1.5.4 but in 1.4.5 it will contain the correctly generated password.

Packer version

From 1.5.4

Operating system and Environment details

This is the case when running packer from both a Windows and Linux environment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions