# binary module seems does not work

**URL:** <https://forum.ansible.com/t/binary-module-seems-does-not-work/12713>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [April 23, 2013, 12:27pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713 "2013-04-23T12:27:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 23, 2013, 12:27pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/1 "2013-04-23T12:27:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shirou](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@shirou](https://forum.ansible.com/u/shirou)\
**Post date:** [April 23, 2013, 1:22pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/2 "2013-04-23T13:22:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 23, 2013, 1:45pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/3 "2013-04-23T13:45:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shirou](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@shirou](https://forum.ansible.com/u/shirou)\
**Post date:** [April 23, 2013, 2:44pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/4 "2013-04-23T14:44:26Z")

</div>

Here is the sample time module source.

[https://gist.github.com/shirou/5444078](https://gist.github.com/shirou/5444078)

This is almost same as [http://ansible.cc/docs/moduledev.html#reading-input](http://ansible.cc/docs/moduledev.html#reading-input).

This is a sample output using test-module.  
(note: time format is different from other language.)

&nbsp;&nbsp;&nbsp;% ./test-module -m ./main -a "f=2006" # with argument

---

<div class="post-metadata">

**Author:** ![Kelsey\_Hightower](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@Kelsey\_Hightower](https://forum.ansible.com/u/Kelsey_Hightower)\
**Post date:** [August 20, 2013, 3:00am UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/5 "2013-08-20T03:00:23Z")

</div>

> Here is the sample time module source.
> 
> [https://gist.github.com/shirou/5444078](https://gist.github.com/shirou/5444078)
> 
> This is almost same as [http://ansible.cc/docs/moduledev.html#reading-input](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
> 
> > 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?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 20, 2013, 7:40pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/6 "2013-08-20T19:40:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shirou](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@shirou](https://forum.ansible.com/u/shirou)\
**Post date:** [August 21, 2013, 6:39am UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/7 "2013-08-21T06:39:08Z")

</div>

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](http://www.ansibleworks.com/docs/moduledev.html)

Regards,  
WAKAYAMA Shirou

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 21, 2013, 11:59am UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/8 "2013-08-21T11:59:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Olivier\_Wulveryck](https://avatars.discourse-cdn.com/v4/letter/o/e68b1a/32.png) [@Olivier\_Wulveryck](https://forum.ansible.com/u/Olivier_Wulveryck)\
**Post date:** [April 22, 2016, 2:40pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/9 "2016-04-22T14:40:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 22, 2016, 2:49pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/10 "2016-04-22T14:49:09Z")

</div>

There is a pull request at [https://github.com/ansible/ansible/pull/13771](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.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 22, 2016, 2:55pm UTC](https://forum.ansible.com/t/binary-module-seems-does-not-work/12713/11 "2016-04-22T14:55:24Z")

</div>

no support in ansible yet, but might have soon thanks to this [https://github.com/ansible/ansible/pull/13771](https://github.com/ansible/ansible/pull/13771)
