There is a pull request at https://github.com/ansible/ansible/pull/13771 to add support for binary modules. The plan is to merge it soon after 2.1 is released. Support for binary modules will be included in the 2.2 release.
On Fri, Apr 22, 2016 at 9:40 AM, Olivier Wulveryck < [email protected]> wrote: > Hello, > > I'm facing the exact same problem today. > I've developed a module in go (actually mainly because I know this > language, and also because I've a bunch of library I'm using to connect to > a specific backend). > Anyway, the module is running ok with the test-module utility (as > described in the ansible documentation), but I'm totally unable to make it > run within a playbook > > The error is "module (mymodule) is missing interpreter line". > > I'm aware that this thread is more than 2 years old, but I cannot find any > recent information on google and the documentation keeps on mentioning that > it is possible to develop a module in *any* language. > > Do you have any workaround to propose to use a binary module? Were you > able to achieve your goal? > > Regards, > > Olivier > > Le mercredi 21 août 2013 13:59:58 UTC+2, Michael DeHaan a écrit : >> >> Yes, we're aware! >> >> It should be possible to detect the module is binary and not look for the >> shebang in it, and otherwise treat it like a non-Python module in another >> language. >> >> One thing that we /may/ wish to do is automatically send binary modules >> JSON, rather than the key=value legacy stuff it currently does by default >> (see "WANTS_JSON" in the code for the hack we did for the Ruby modules). >> >> (I should aspect Go should have a decent JSON library available, right?) >> >> Then the module would just need to look at argv[1] and read in that file >> as JSON and should be fine. >> >> I would suspect there's not a HUGE advantage to doing this, as while the >> module is now binary, the arguments file must be transferred seperately -- >> I'd almost bet the Python method is still faster and you can still load C >> libraries from there. >> >> >> >> >> On Wed, Aug 21, 2013 at 2:39 AM, shirou <[email protected]> wrote: >> >>> Hi Michael and Kelsey, >>> >>> I am writing modules by python because I am familiar than golang >>> (currently!) >>> >>> However, I think this is not only golang specific issue. >>> On the ansible website[1], "any language is possible. " it includes C++. >>> Some people may want to write modules by C++ with existing libraries. >>> >>> >>> [1] http://www.ansibleworks.com/docs/moduledev.html >>> >>> Regards, >>> WAKAYAMA Shirou >>> >>> >>> 2013/8/21 Michael DeHaan <[email protected]>: >>> > This isn't something I've spent time on, but it seems like it would be >>> a >>> > pretty basic patch that I would consider. >>> > >>> > Still interested in it for Go purposes? Curious about the use case >>> knowing >>> > who you work for :) >>> > >>> > --Michael >>> > >>> > >>> > >>> > >>> > On Mon, Aug 19, 2013 at 11:00 PM, Kelsey Hightower >>> > <[email protected]> wrote: >>> >> >>> >> >>> >> >>> >> On Tuesday, April 23, 2013 7:44:26 AM UTC-7, Shirou w wrote: >>> >>> >>> >>> Here is the sample time module source. >>> >>> >>> >>> https://gist.github.com/shirou/5444078 >>> >>> >>> >>> This is almost same as >>> >>> http://ansible.cc/docs/moduledev.html#reading-input. >>> >>> >>> >>> This is a sample output using test-module. >>> >>> (note: time format is different from other language.) >>> >>> >>> >>> % ./test-module -m ./main -a "f=2006" # with argument >>> >>> *********************************** >>> >>> RAW OUTPUT >>> >>> {"time":"2013"} >>> >>> >>> >>> %./test-module -m ./main # without argument >>> >>> *********************************** >>> >>> RAW OUTPUT >>> >>> {"time":"2013-04-22 23:37:13"} >>> >>> >>> >>> Since go-lang has JSON library in core library, it is easy to produce >>> >>> JSON output. >>> >>> >>> >>> -- >>> >>> WAKAYAMA Shirou >>> >>> >>> >>> >>> >>> 2013/4/23 Michael DeHaan <[email protected]>: >>> >>> > Tell you what, do you have a sample source for a go module that >>> >>> > produces >>> >>> > JSON output? >>> >>> > >>> >>> > Just a "Hello World" is ok -- I just don't know enough go to write >>> one. >>> >>> > >>> >>> > I could then see what it would take to transfer it unaltered. >>> >> >>> >> >>> >> Did this ever get resolved? Michael, did you ever get this to work? >>> >> >>> >>> >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>> > On Tue, Apr 23, 2013 at 9:22 AM, shirou <[email protected]> >>> wrote: >>> >>> >> >>> >>> >> Go-lang compiler makes a static-linked binary that includes all >>> of the >>> >>> >> required libraries. This means a module becomes more independent >>> from >>> >>> >> target hosts environment. No other files (such as libc.so) are >>> >>> >> required to execute that module. >>> >>> >> That's why I want to use go-lang for writing modules. speed is >>> second >>> >>> >> ;) >>> >>> >> >>> >>> >> Anyway, thank you for accepting my concern. >>> >>> >> >>> >>> >> I like the design principles of ansible-project and I keep on >>> using >>> >>> >> ansible. >>> >>> >> >>> >>> >> Thank you >>> >>> >> -- >>> >>> >> WAKAYAMA Shirou >>> >>> >> >>> >>> >> >>> >>> >> 2013/4/23 Michael DeHaan <[email protected]>: >>> >>> >> > I don't think there's going to be that many needs where the >>> system >>> >>> >> > will >>> >>> >> > require a native binary module for speed reasons, though I would >>> >>> >> > support >>> >>> >> > patches that detected the file was binary and attempted >>> >>> >> > to /not/ process it or transfer it differently, I guess, if they >>> >>> >> > were >>> >>> >> > small >>> >>> >> > and simple enough. >>> >>> >> > >>> >>> >> > It's just not something many people are going to use. >>> >>> >> > >>> >>> >> > As for why we modify modules, there are definitely some things >>> we do >>> >>> >> > with >>> >>> >> > modules to replace shebang lines on different systems (suppose >>> one >>> >>> >> > uses >>> >>> >> > one >>> >>> >> > python, another another, and one isn't in the user's path >>> because we >>> >>> >> > don't >>> >>> >> > trust the user) -- this is the ansible_python_interpreter >>> mechanism. >>> >>> >> > What >>> >>> >> > we do with our own python modules to embed arguments and >>> optimize >>> >>> >> > the >>> >>> >> > way >>> >>> >> > data is transferred in another story, this would be about the >>> >>> >> > 'non-newstyle-module' code path. >>> >>> >> > >>> >>> >> > --Michael >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > On Mon, Apr 22, 2013 at 11:19 AM, Shirou w <[email protected]> >>> >>> >> > wrote: >>> >>> >> >> >>> >>> >> >> Hi, all >>> >>> >> >> >>> >>> >> >> I made a simple time module by using golang ( >>> http://golang.org/). >>> >>> >> >> >>> >>> >> >> It can run with "test-module" but when I run with ansible >>> command, >>> >>> >> >> did >>> >>> >> >> not >>> >>> >> >> work. >>> >>> >> >> >>> >>> >> >> % ansible -vvv all -m time -M . --ask-pass >>> >>> >> >> SSH password: >>> >>> >> >> <127.0.0.1> ESTABLISH CONNECTION FOR USER: sample on PORT 22 TO >>> >>> >> >> 127.0.0.1 >>> >>> >> >> <127.0.0.1> EXEC /bin/sh -c 'mkdir -p >>> >>> >> >> $HOME/.ansible/tmp/ansible-1366642710.56-42277018789729 && >>> chmod >>> >>> >> >> a+rx >>> >>> >> >> $HOME/.ansible/tmp/ansible-1366642710.56-42277018789729 && echo >>> >>> >> >> $HOME/.ansible/tmp/ansible-1366642710.56-42277018789729' >>> >>> >> >> <127.0.0.1> REMOTE_MODULE time.go >>> >>> >> >> 127.0.0.1 | FAILED => failure encoding into utf-8 >>> >>> >> >> >>> >>> >> >> This is caused by _copy_module in the runner/__init__.py. >>> >>> >> >> I am new to ansible but I think the _copy_module assumes only >>> >>> >> >> string >>> >>> >> >> module. >>> >>> >> >> Is this true or wrong? if true, ansible will not support binary >>> >>> >> >> module? >>> >>> >> >> >>> >>> >> >> BTW, golang makes static linked binary which can just copy to >>> the >>> >>> >> >> remote >>> >>> >> >> and run. >>> >>> >> >> It may become good solution to writing module which requires >>> speed. >>> >>> >> >> (ah, the file size is big just a little...) >>> >>> >> >> >>> >>> >> >> Thank you. >>> >>> >> >> >>> >>> >> >> -- >>> >>> >> >> You received this message because you are subscribed to the >>> Google >>> >>> >> >> Groups >>> >>> >> >> "Ansible Project" group. >>> >>> >> >> To unsubscribe from this group and stop receiving emails from >>> it, >>> >>> >> >> send >>> >>> >> >> an >>> >>> >> >> email to [email protected]. >>> >>> >> >> For more options, visit >>> https://groups.google.com/groups/opt_out. >>> >>> >> >> >>> >>> >> >> >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > >>> >>> >> > -- >>> >>> >> > Michael DeHaan <[email protected]> >>> >>> >> > CTO, AnsibleWorks, Inc. >>> >>> >> > http://www.ansibleworks.com/ >>> >>> >> > >>> >>> >> > -- >>> >>> >> > You received this message because you are subscribed to the >>> Google >>> >>> >> > Groups >>> >>> >> > "Ansible Project" group. >>> >>> >> > To unsubscribe from this group and stop receiving emails from >>> it, >>> >>> >> > send >>> >>> >> > an >>> >>> >> > email to [email protected]. >>> >>> >> > For more options, visit >>> https://groups.google.com/groups/opt_out. >>> >>> >> > >>> >>> >> > >>> >>> >> >>> >>> >> -- >>> >>> >> You received this message because you are subscribed to the Google >>> >>> >> Groups >>> >>> >> "Ansible Project" group. >>> >>> >> To unsubscribe from this group and stop receiving emails from it, >>> send >>> >>> >> an >>> >>> >> email to [email protected]. >>> >>> >> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >> >>> >>> >> >>> >>> > >>> >>> > -- >>> >>> > You received this message because you are subscribed to the Google >>> >>> > Groups >>> >>> > "Ansible Project" group. >>> >>> > To unsubscribe from this group and stop receiving emails from it, >>> send >>> >>> > an >>> >>> > email to [email protected]. >>> >>> > For more options, visit https://groups.google.com/groups/opt_out. >>> >>> > >>> >>> > >>> >> >>> >> -- >>> >> You received this message because you are subscribed to the Google >>> Groups >>> >> "Ansible Project" group. >>> >> To unsubscribe from this group and stop receiving emails from it, >>> send an >>> >> email to [email protected]. >>> >> >>> >> For more options, visit https://groups.google.com/groups/opt_out. >>> > >>> > >>> > >>> > >>> > -- >>> > Michael DeHaan <[email protected]> >>> > >>> > CTO, AnsibleWorks, Inc. >>> > http://www.ansibleworks.com/ >>> > >>> >> >> >> >> -- >> Michael DeHaan <[email protected]> >> CTO, AnsibleWorks, Inc. >> http://www.ansibleworks.com/ >> >> -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/852f7814-35e5-4672-8a03-b8ed84d6bf05%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/852f7814-35e5-4672-8a03-b8ed84d6bf05%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v8fsfB-o%2BBtQnya%3DUmUApEkPX8EnxTPa%3DYFdEeQyZ%3DzTg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
