Getting Started with Ansible Module Development on Mac OS X
26 May 2015Ansible is great.
Sometimes though you may need to improve on modules, or patch them, or just create new ones.
Here’s what I did (and would do again) to get started:
- First, go to the IRC channel on freenode (#ansible-devel) and ansible development group (https://groups.google.com/d/forum/ansible-devel) to make sure someone isn’t already working on the feature. I would also browse/search the issues on the github page to see if someone has a related outstanding issue. If you don’t know what IRC/freenode are start here: https://freenode.net/using_the_network.shtml
- If at this point you still want to proceed…read this: https://docs.ansible.com/developing_modules.html
- Clone the main ansible repo. https://github.com/ansible/ansible
- Setup your environment to run against the ansible source you just cloned.
source ansible/hacking/env-setup
- Fork the repo where the module currently lives, either
https://github.com/ansible/ansible-modules-core
orhttps://github.com/ansible/ansible-modules-extras
. If you’re developing a new module you most likely want to put it inansible-modules-extras
. - Create a branch to work in.
- Setup your environment to run against these module locations first (if you didn’t do this step ansible would look at the main ansible directory cloned above first.)
export ANSIBLE_LIBRARY=~/ansible-modules-core:~/ansible-modules-extras
- Setup an ansible playbook that uses the module you want to change.
- Confirm the playbook runs before you make changes.
- Make changes to the module.
- Confirm the changes work.
- Commit your changes to your branch.
- Push your changes to your fork.
- Open a PR.
Note: There is a test-module
script that you can use to execute a module
without writing a playbook. See http://docs.ansible.com/developing_modules.html#testing-modules
In my case, the module I was changing didn’t work with the test-module
script,
so I used the steps I outlined above.