How to build Ansible?

I asked this in github issue #55900 but got directed here.

I want to contribute to Ansible.

I have a patch I want to submit. But first I need to run it to make sure it actually works.

How can I run Ansible from source?

The github README and the Contributing to Ansible doc pages do not explain how.

What I tried:

I looked in README.rst, but there are no instructions there.

I see a Makefile, and no config.sh or autoconfig.sh. So I try just make.

ImportError: No module named **packaging.version**

I see requirements.txt. There is no comment in there or anywhere else telling me whether that’s for python 2 or 3.

virtualenv env -p $(which python3)
. ./env/bin/activate
pip install -r requirements.txt
make

Same error

pip install packaging
make

Now that does build. But why is packaging not in requirements.txt?

Then I try to find where the build output is.

$ find ./ -name ansible | xargs file
./build/lib/ansible: directory
./build/scripts-3.6/ansible: Python script, ASCII text executable
./bin/ansible: Python script, ASCII text executable
./docs/docsite/js/ansible: directory
./lib/ansible: directory
./packaging/macports/sysutils/ansible: directory
./packaging/port/sysutils/ansible: directory
./test/integration/targets/ansible: directory
./test/runner/injector/ansible: symbolic link to python.py

Then ./bin/ansible --version. That fails with ModuleNotFoundError: No module named 'ansible'

Same with ./build/scripts-3.6/ansible --version.

I want to contribute, but I just can’t figure out how.

  • What dependencies do I need?
  • python 2 or 3?
  • do I need to run setup.py or something to install the output of the build process into a virtualenv in order to actually test it?

Thanks,
Matt

Ah, I ended up getting a reply on that github thread.

The answer is here: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#running-from-source

I have submitted PR #55902 to add that link to the README.

Regards,
Matt