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

{{ .WinRMPassword }} is not interpolated #56

Closed
flixman opened this issue Jul 2, 2021 · 3 comments · Fixed by #60
Closed

{{ .WinRMPassword }} is not interpolated #56

flixman opened this issue Jul 2, 2021 · 3 comments · Fixed by #60
Labels

Comments

@flixman
Copy link

flixman commented Jul 2, 2021

I have migrated my packer files from json to hcl2. The ansible provisioner does not recognize anymore the "{{ .WinRMPassword }}" template to add the ansible_password as extra-arguments. I have checked the source code of the plugin and I have found out that in case ansible_password is not found in extra-arguments, connection is winrm and 'use proxy' is false, the password gets added by default to the command line and everything works, but maybe this should be added somewhere to the documentation?

@flixman flixman added the bug label Jul 2, 2021
@SwampDragons
Copy link
Contributor

HCL uses a different structure for build variables: https://www.packer.io/docs/templates/hcl_templates/contextual-variables#build-variables

Try using ${build.Password} instead of {{.WinRMPassword}}

@flixman
Copy link
Author

flixman commented Jul 3, 2021

hey @SwampDragons, thank you for your answer. I will give it a try, and indeed seems it will work, but this documentation then conflicts with that of the ansible provisioner, https://www.packer.io/docs/provisioners/ansible/ansible, where it says
"[...] For example, if you are running a Windows build on AWS, Azure, Google Compute, or OpenStack and would like to access the auto-generated password that Packer uses to connect to a Windows instance via WinRM, you can use the template variable {{.WinRMPassword}} in this option. [...]".
In any case, knowing that you guys are aware of this, I guess I can close this issue? :-)

@flixman flixman closed this as completed Jul 3, 2021
@SwampDragons
Copy link
Contributor

I'll update the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants