Using Updated Modules With Stable Ansible

12 Dec 2017

There are many reasons to want to use newer modules than a chosen stable Ansible core release:

When that happens, thankfully you don’t have to run off your own megamerge branch of ansible.

My approach for this is to use the default library directory feature — create a library directory in the top level of your playbooks repository, and put any modules that you need but aren’t yet in the version of ansible you’re using there.

I also keep a README.md file in the library directory. It looks a bit like:

|Module                     | PR                                            | Notes           |
|---------------------------|-----------------------------------------------|-----------------|
|cloudfront_distribution.py | https://github.com/ansible/ansible/pull/31284 | Unmerged        |
|ec2_placement_group.py     | https://github.com/ansible/ansible/pull/33139 | Available in 2.5|

Keeping track of why I’m using each module allows me to remove released modules after each major or minor Ansible release.

One minor caveat: if the module you’re using relies on recent updates to module_utils shared libraries, you might need to either copy those into the module or instead use the module_utils config directive in ansible.cfg and copy the relevant module_utils file into your codebase as well.

— I’ve been there.