I’m curious as to how best to develop and distribute a 3rd-party module. Currently I’m working in an Ansible development branch. My module is in the library folder, and I’m running tests using hacking/test-module. This has been a good workflow, especially when using the --debugger flag.
In order for me to run my module in production I’m running “make install”, which creates a new Ansible build. I’m guessing that in order for others to use this module they would have to do the same.
I’m working on two modules, both a digitalocean API v2 module and a JSON config file manipulation module. Both of these I think could be included in core eventually. Though for now, I’d rather develop these in their own repositories independent of the Ansible project.
How might a third-party module be distributed? I’ve read about adding a /library file relative to a playbook (cool!). For more general use modules that I’d like to distribute to several people for use across multiple projects, how might a user “install” a module without executing a new Ansible build?
Just copy that one module file in said library/ folder is more than
enough.
I have some (old) modules I made available through a more general plugins
repo:
https://github.com/ginsys/ansible-plugins/tree/devel/library
In most cases, a module is just one file, so whatever means should work.
That being said, nowadays a lot of common code can now be placed in
lib/ansible/module_utils/
IIRC that location is not 'pluggeable'', so no custom location like other
plugins where to put shared code fragments.
This is something that still should be implemented IMHO. IIRC Michael was
open to that.
Serge
Alright, I can see this working. In my development folder, I’ll put my module in a /library folder and a playbook at the root that I use for running various tests against the module, like…
myModuleProject
– library
– myModule
– test_playbook.yml
Still doesn’t completely solve the distribution problem. But are you saying that if I put a module file in to /lib/ansible/module_utils, it will run? Guess I’ll go give it a shot…
Still doesn't completely solve the distribution problem.
Depends. I was just saying that if you document a module can be put in
library/, you just need to distribute that single module file.
But are you saying that if I put a module file in to
/lib/ansible/module_utils, it will run? Guess I'll go give it a shot...
If you put a "python module"-style file to be imported into your module
file in that location, then yes.
Serge