common library for multiple modules

We are currently refactoring the digitalocean modules (not use an external library, migrate everything to the v2 API).
all modules (do_droplet, do_tag, do_sshkey, do_domain, do_storage) will need some common code.

The most basic stuff is just a simplification of invoking fetch_url:

  • Authentication handling
  • common base URL
  • common response/error handling
  • JSON-fying data
  • handling the “paging” of the API responses

We would love to place this in some common “digitalocean” module. But as far as I can see that would have to be placed in ‘ansible’ itself
(e.g. in module_utils/urls.py). Is there any mechanism to keep the common part in ansible-modules-core?
On the other hand everything (besides the paging stuff) might be useful to other projects as well.

So

  1. should we add some “Rest” stuff to urls.py in ‘ansible’?
  2. Is it possible to keep that in a do_common module/something in ‘ansible-modules-core’?

The module_utils directory is the proper place for it and a do_common.py can be added there.

After 2.2 is released we plan on merging all repos into a single one to avoid the 2 PRs issue with this feature.