Thursday, September 15, 2016

Deploy using Bamboo and Ansible, getting started

In order to get started with Ansible and Bamboo (talking about latest versions which include the deployment management section) there is very little to do, at least this is what I did

  • get your Bamboo up and running of course
  • prepare one agent with Ansible (pip install ansible or other installation guides)
  • prepare a build and locate your build artifacts
  • share your artifacts so they are picked by the release management module of Bamboo
  • create a deployment project
Now that you have your artifacts and you can prepare software releases is time to move to Ansible:

  • prepare a repository to store your Ansible code, create usual folders for Ansible
  • commit your playbook, roles, vaults, inventories
As a next step we put things together, the release and the ansible scripts meet at environment level:

  • checkout the ansible code
  • add a task to download the artifacts in a subfolder called "files"
  • invoke Ansible - any command to copy files to remote destination will be searching under "files" and will do the shipping for you. 

To make life easier you can make a special Ansible role that removes versions from the release files so that roles can reference them easier, for example my.software-1.3.rpm could become my.software.rpm

And you are done, now starts the Ansible fun. Personally I create one Bamboo environment for each inventory file and name them in a way that I can trace easy which env is tied to which environment.

In case you have sensitive information use vaults, encrypt files in you Ansible repository, you can keep the password in a file directly on the agent.