packer-plugin-ansible
packer-plugin-ansible copied to clipboard
Ansible provisioner fails in Windows azure build
This issue was originally opened by @nikhilpatne in https://github.com/hashicorp/packer/issues/11840 and has been migrated to this repository. The original issue description is below.
Overview of the Issue
Hi Team, I am trying to create azure windows golden image using packer, I could see packer has successfully able to create windows VM as per publisher,offer, sku I specified, winrm also connected, windows-shell and powershell provisioners also working fine, but when I tried to use ansible provisioner it fails, with error message: "msg": "basic: the specified credentials were rejected by the server",
. I dont see any option in azure-arm to set winrm_username and winrm_password. as per my understanding packer
is the default username that packer uses and tried to pass winrm password through build variable like "winrm_password=${build.Password}"
and ansible_env_vars = ["WINRM_PASSWORD={{.WinRMPassword}}"]
but still the same issue. Could you please help me, what i am missing in ansible provisioner, I tried almost all ways mentioned in documentation for ansible provisioner
Packer version
From 1.8.0
Simplified Packer Template
source "azure-arm" "autogenerated_1" { client_id = "${var.client_id}" client_secret = "${var.client_secret}" communicator = "winrm" custom_data_file = "" image_offer = "WindowsServer" image_publisher = "MicrosoftWindowsServer" image_sku = "2019-Datacenter" image_version = "latest" location = "${var.location}" os_type = "Windows" polling_duration_timeout = "0h30m0s" private_virtual_network_with_public_ip = true
managed_image_name = "myimg" managed_image_resource_group_name = "${var.storage_resource_group}"
subscription_id = "${var.subscription_id}" temp_compute_name = "winpackervm" temp_resource_group_name = "windows-rg" tenant_id = "${var.tenant_id}" vm_size = "Standard_DS2_v2" winrm_insecure = true winrm_timeout = "5m" winrm_use_ssl = true }
build { sources = ["source.azure-arm.autogenerated_1"]
provisioner "windows-shell" { inline = ["ipconfig /all"] }
provisioner "ansible" { use_proxy = false user = "packer" playbook_file = "../tagging.yml" ansible_env_vars = ["WINRM_PASSWORD={{.WinRMPassword}}"] extra_arguments = [ "-e", "ansible_winrm_server_cert_validation=ignore", "-vvv" ] }
}
Operating system and Environment details
RHEL8
Set the env var PACKER_LOG=1
for maximum log detail.