-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
First pass at allowing binary modules #13771
Conversation
he, i was doing same last night, but ran out of gas. |
i was actually going to leverage the stat module to get the 'binary status' |
Just as an example, this is the golang code for the module I was testing with:
A more full featured example can be found at: https://gist.github.com/sivel/ccd81bdfb31ca0c0e05d |
So far it looks like everything is working as expected. I've tested with ssh, paramiko, local, and winrm. I've also mixed non binary and binary modules within the same playbook. See this gist for details about the test playbook and example module: https://gist.github.com/sivel/ccd81bdfb31ca0c0e05d |
This is awesome @sivel. Thanks for taking the time to work on this. I can't wait to see it merged (fingers crossed). |
Thanks for effort @sivel can't wait to see this merged too. |
dfbf085
to
fc55bd1
Compare
I've added integration tests for binary modules. Executed like:
My
In my particular case |
The current build failure is due to travis not properly installing python2.4 and not related to this PR. |
22f4e0f
to
6b17eb8
Compare
Rebased and merge conflicts resolved due to b4b24a0 |
6c1ce7b
to
069424c
Compare
Per the core meeting today, this will be targeted for implementation in v2.2, to land in devel after the 2.1 release (https://meetbot.fedoraproject.org/ansible-meeting/2016-04-12/ansible_core_meeting.2016-04-12-19.02.html) I've rebased against devel, and handled merge conflicts. I have fixed failing tests, but have not added any additional unit tests around this as of yet. Integration tests are there, but are not currently running as part of |
224bf01
to
ab03ca5
Compare
@@ -549,7 +563,7 @@ def _execute_module(self, module_name=None, module_args=None, tmp=None, task_var | |||
|
|||
# Fix permissions of the tmp path and tmp files. This should be | |||
# called after all files have been transferred. | |||
self._fixup_perms(tmp, remote_user, recursive=True) | |||
self._fixup_perms(tmp, remote_user, recursive=True, execute=is_binary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking perhaps we should always set execute=True? In the python module case, it is still a script intended to be executed so it seems reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We execute the interpreter directly by substituting ansible__interpreter so not sure that this is needed (unless we want to change to always execute the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two things I was thinking about were: When someone sets ANSIBLE_KEEP_REMOTE_FILES=1 and then wants to execute the wrapper and async. async currently sets execute=True so that async_wrapper can execute the module that was copied over. Started me wondering if there's any harm to just setting execute=True by default.
I like this for 2.2. I reviewed everything except the shell changes. @nitzmahone you probably shold look at those since it looks like powershell has the most complexity to it. About the integration tests -- it would be nice to turn it on by default. I wonder if we could build the go module and have it in the git repo in addition to the source code? Would that work? What do others think about that? |
would resemble something similar to:: | ||
|
||
{ | ||
"name": "Ansible", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use something different than name and Ansible here to be clear that this the module parameters rather than more special variables. Maybe something like "data" like the ping module uses?
@abadger agreed on all counts- if the integration tests aren't running on this all the time, it will get broken. I need to try with a .NET module and see, but in that case, we definitely don't want any interpreter (just direct exec the module) |
textchars = bytearray(set([7, 8, 9, 10, 12, 13, 27]) | set(range(0x20, 0x100)) - set([0x7f])) | ||
|
||
with open(module_path, 'rb') as f: | ||
start = f.read(1024) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to re-read this file or can we adapt this code to use module_data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do some testing, and look at how we are opening the file elsewhere.
A few minor comments. Everything else looks good. If this is passing tests and you think it's ready to merge to devel then I'm okay with it. Tests -- I'm not sure how long compiling the module takes but I expect it's minimal. I think you're right, we probably should put golang into the docker images. |
…o the top of the stack
…e already has access to it
I find it suboptimal to download go and and build stuff during the tests, while on the other hand we try preinstalling packages where possible to make travis faster. Maybe you can instead use precompiled binaries? |
This change broke my tests for the new images on opensuseleap and ubuntu16.04 due to missing with curl/wget (why use both?). There's something broken with the tests in general, because even the travis run that gave you a green light for the merge was done without curl installed: |
Ah, now I understand the idea, it uses either curl or wget. Still... |
We will be moving adding golang to the docker containers. To get things in faster we didn't block this to wait on updating the images. This is on the to do list. We however will still do compilation at build, and will not be storing the binary files in the repo. |
It is on the todo list, meaning it still needs to be worked on. There is no PR currently. |
#6374 is a bit out of date with all of the changes for 2.0.
This PR adds some proof of concept changes that allow ansible to utilize binary modules that have no shebang and whatnot.
binary detection is done similarly to the
file
command using a concept found at http://stackoverflow.com/a/7392391There are no doubt some things missing right now, but this is working for the standard action (
not tested with async) and thessh
transport.A few things that need to be looked at:
async(Async seems to work fine per my tests)windows(Had to change some things around to allow.exe
extensions for modules, but working now, assumes windows binaries are always.exe
)binaries other than go, and non ELF(Have testing things from executables, to images, to PDFs, which all report properly)