-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
"Packer" Ansible connection for WinRM breaks on Ansible 2.3.0 #4904
Comments
Thanks for the report. I can duplicate this and have dug in to try to resolve it. I'll reach out to Matt Davis shortly. |
There doesn't seem to be anything we can do about this until ansible/ansible#25012 is released. |
I do confirm as well that I was able to reproduce this issue. (latest devel branch, ansible 2.4.0) |
ansible/ansible#25012, which resolves this issue, has been merged and is scheduled for release in 2.4. It's also in the current release candidates for 2.3.2 (re: https://github.com/ansible/ansible/releases). |
Is there an update to the Packer side for this to work with Ansible 2.4+? |
Hmm, I was having issues using Ansible 2.4.0, with similar issues here. Upgraded Ansible to 2.4.1 and also added the changes seen in #5162, and now it's working fine. |
Never mind, I still get some issues occasionally:
With more debug, on a different run...
And the weird thing, is that it always happens during the |
I'm also having the same problem (Packer 1.1.2 with Ansible 2.4.2). |
@SNikalaichyk I couldn't get Packer + Ansible working consistently so I implemented jborean93's solution. More details of the solution can be seen in the google group post: https://groups.google.com/forum/#!starred/packer-tool/AXZSY6UoBNo |
@surferL, thanks! If my playbooks will continue to fail unexpectedly, I think I'm going to do the same. I still hope for the proper fix though. |
Thanks @SNikalaichyk for pinging me in this. If the maintainers of Packer are reading this feel free to reach out to me as I’m interested in trying to solve this issue and hopefully get Packer working with the native |
@jborean93 I've been following along and would appreciate any help we can get regarding the plugin that packer's ansible-remote module uses. |
@jborean93 I'll gladly help you validate any assumptions you have, though we don't as a rule spend much time on the ansible provisioner. It's supported by the community, as we prefer to invest our limited time on things like the shell provisioner (which is Hashicorp-supported), which can also be used to run ansible -- as I believe you've pointed out. But let me know what snags you're hitting and we can try to work through them 🙂 |
Sounds good, I just installed Go and downloaded the repo to try and play around with it a bit but will see how I go. Is there a reason why the SSH connector was used historically or is it just something that the community never got round to adding support for other connection plugins? |
I'm not totally sure, though I would assume the latter. Here's the original PR and associated conversation for come context: #1969 |
@jborean93 I'm the original author of the ansible provisioner, so I can help answer any questions you have about the tradeoffs made. Packer only exposes a simple interface, |
@jborean93 also keep in mind that Packer allows one to provision various kinds of images, not all of which corresponds to machines (e.g. docker images); there isn't always a connection that could be used even if Packer exposed its connection to the provisioner. Ansible, on the other hand, assumes that it's talking over a network. So the ansible provisioner sets up an SSH connection for Ansible to talk to, then it translates SSH messages into Packer communicator method calls. |
@bhcleek thanks for the info, much appreciated. So I just have a few more questions for either yourself or @SwampDragons
Unfortunately using this SSH connection to translate commands/files to the Windows host means a lot of the features we have implemented in Ansible for Windows to not work like
For a high level description of what I am hoping to do
This does mean Thanks, hopefully that can get me started and I'm not biting off more than I can chew. |
@jborean93 That approach has been proposed several times, but is fundamentally incompatible with how Packer works. For background, I'd recommend that you read
It's very easy to recognize how the approach you propose might work to provision a Windows AMI on EC2, but it would be incompatible with building a docker image; Packer fully separates builders from provisioners; provisioners can make no assumption about the underlying communication mechanism. |
Thanks, I'll have a read through those, unfortunately it looks like what I want to do goes against how Packer is designed to work so I don't really see how I could fix this. Even if we were to make it work again with a non pipelining model there is always the chance it could break again in the future as we don't test for it. Plus some of the special features Ansible has like become and async will never work as they are designed for a pipeline like state. I understand your point about non standard images but TBH I think it is a bit shortsighted to not take advantage of using some of the connection plugins Ansible has when connecting to different platforms like Windows and Docker (full list is here https://docs.ansible.com/ansible/devel/plugins/connection.html#plugin-list). In the end this isn't my project and I'm just a user so I'm fine with continuing to use |
I would definitely welcome any improvements to the connection plugin. Ansible's connection plugins have been a moving target, especially as Windows support has matured. I need to sync back up with Ansible and provide some details about what we've had to do to get Ansible to work with the Powershell shell type and an SSH connection. In the meantime, though, any guidance that you can provide to make the connection plugin more stable is very appreciated. |
I'll need to test it out but I'm wondering if modifying the existing custom plugin to support pipelining with Windows will work. I've got a very early stage PR to get Ansible communicating with Windows using the Win32-OpenSSH port here ansible/ansible#33074. This has not been tested to the full extent but it did work for the basics that I tried it with. I do agree the connection plugin side is a moving target right now, even we are trying to understand how we want to handle using the SSH plugin to work across non POSIX platforms like Windows. |
So, if I use |
@SNikalaichyk That seems like a really reasonable ask. I'll see if I can figure out a simple way for you to access it from the template. |
@SNikalaichyk is there a reason you aren't willing to just set a static password for winrm in your user_data file? |
@SwampDragons, we're using monthly AWS Windows AMIs. And in general, embedding passwords is a bad practice. |
@SNikalaichyk I lost track of your request because I wasn't tracking it in a separate issue; I've created one #5895 |
If using shell-local is the preferred method for dealing with Ansible on Windows, then perhaps #3331 should be reopened? |
Any update on how to use In #5845 it was agreed, that using the Actually getting the IP address (needed by Ansible) form the VM which is being build by Packer is not very easy... Any ideas - how this may be solved? |
@SNikalaichyk this patch #6251 should allow you to use the winrm password in shell-local; I've uploaded some builds of the patch on that PR so you can test it if you'd like. |
@SwampDragons, thanks a lot! For those interested, my current workflow is:
|
@SNikalaichyk - thank you for the short description. |
I've run into this issue as well. Using Ansible 2.5.4 the documented way to run packer with Ansible fails. However if I purposely downgrade to Ansible 2.4.0 everything works as expected. Has anyone made any progress with this issue? Below is my traceback when running the Ansible provisioner. ` ` |
@adarobin Please do share your working example with shell-local that would help me a lot. Thanks. |
Here are the provisioners I am using to generate a host file for use with ansible called with the shell-local provisioner:
That Edit: This gist should eliminate the dox2unix step though I have not tested it yet myself. |
If you are interested in building windows using packer+ansible with |
@adarobin , I don't understand because I have the same connection_plugin as you, except for the documentation part: https://github.com/Wenzel/bug_packer_ansible/blob/master/ansible/connection_plugins/packer.py And I still get errors on 2.6.0. Any clue ? 🤔 |
Yes you need the documentation part. It is used by Ansible to determine what options are available to the connection plugin. It’s more than just documentation, it is self documenting code. |
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. |
packer version:
1.0
packer host: Ubuntu 16
builder type:
amazon-ebs
Problem description:
Ansible 2.3.0 introduces a rewrite of the way it sends commands to winrm-based nodes. This causes the current "packer" connection plugin to fail.
Here's the relevant log output:
It's probably a good idea to get in touch with Matt Davis at Redhat to discuss how to solve this, as he's responsible for the Windows stuff in Ansible core.
On the same node, running Ansible v 2.2.0 suceeds, so there's no doubt this is related to the WinRM rewrite in Ansible 2.3.0.
The text was updated successfully, but these errors were encountered: