relaxdiego (Mark Maglana's Technical Blog)

Writing Ansible Modules Part 4 - Submitting Code Upstream

Sep 30, 2016
Est. read: 2 minutes

Co-Written by Andreas Hubert

This is part 4 of a series of articles. For other parts, see the introductory article.

Time To Push to Origin!

Run the following from the ansible repo:

$ git add cloud/
$ git add test    
$ git commit -m "First module including tests"
$ git push origin

Head on over to your Github fork and create a pull request out of the commit you just pushed. Once the PR has been created, copy the PR’s URL to your clipboard since you will need to reference it from the next PR we will create next.

Now head on over to your Github fork of the ansible repo and create a pull request out of the commit you just pushed. In the PR’s description, make sure to paste the previous PR’s URL so that the ansible team knows which modules the tests are for. Once this PR is made, copy its URL as well.

Head back to the first PR you made and modify the description by pasting the second PR’s URL. This is so that the ansible team will know the tests for this PR. This may seem cumbersome and it is but it’s only temporary and will become a single PR setup once the two repos have been combined.

Always make sure that your topic branch is based off of the HEAD of the parent branch. In our case above, we created test_branch off of upstream/devel. While working on test_branch, new commits are merged to upstream/devel. It is, therefore, a good idea to do this regularly:

$ git add .
$ git commit
$ git fa
$ git rebase upstream/devel

Keep doing this until your topic branch is accepted and merged upstream. That should put your topic branch ahead of upstream/devel and avoid any merge conflicts down the line. If you do this regularly and do encounter a merge conflict, it will be easier to fix now than later.

Wazaap, Open Source Contributor!

Yup, I’m talking to you. You’re totally rocking that open source thing!

Before we go our separate ways, I’ll share with you some more resources that you might find helpful as you continue your journey of awesomeness. For that, head over to part 5. Alternatively, you can go back to the the introduction if you want to jump to other parts.