Ansible Tower and Atlassian Bitbucket Pipelines

Bitbucket Pipelines

Bitbucket Pipelines is a continuous delivery service built within Bitbucket Cloud. Bitbucket Cloud is part of the Atlassian suite of tools that also include JIRA Software (ticketing system) and Hipchat (collaboration).

Integrated Solution

This simple integration with Ansible Tower and Atlassian Bitbucket Cloud allows a developer to check-in code and have it deployed - all within an automated workflow.

Here’s an example of using Bitbucket and Ansible Tower to connect your DevOps workflows:

  • SCM - Developer checks code into Bitbucket Cloud

  • Test/Build - Pipelines tests the code, and builds the artifact

  • Deploy - Pipelines calls a job in Tower to deploy the artifact, notify with status

This integration is built using the Tower-CLI tool to issue commands that point at specific Tower Job Template. It’s really just a start to show what is possible. The Tower API and CLI make it easy to integrate Tower into nearly any process.


Get Started

Trigger to Ansible Tower:

Use this example script for launching an Ansible Tower job from Bitbucket Pipelines.

How to use it:

1. Add required environment variables to your Bitbucket environment variables.
2. Make sure you already have an Ansible YAML file.
3. Copy tower.bash to your project.
4. Add tower.bash to your build configuration.

Required environment variables:

  • host: Tower host
  • username: Tower username
  • password: Tower user password
  • ID: ID of job template being launched

Trigger the Ansible job:

  hostval=$(tower-cli config host $host)
  userval=$(tower-cli config username $username)
  passwordval=$(tower-cli config password $password)
  tower-cli config verify_ssl false
  tower-cli job launch --job-template $ID --monitor

  • Uses -ex switches (not shown in snippet above) to exit on first error and to echo command before execution. These help with debugging.
  • Uses tower-cli to configure host, username, and password within the Docker instance.
  • Uses tower-cli to make sure the connection is possible.
  • Uses tower-cli to launch the job.

Build configuration:

  image: python:2.7
    - step:
        script: # Modify the commands below to build your repository.
            - pip install ansible-tower-cli
            - ./tower.bash

  • Uses the standard Python image, which already contains Pip.
  • Installs the Tower CLI, which is already available from PyPI.
  • Triggers the Ansible job.




Ansible and the Atlassian Software Suite

Learn More

Bitbucket Resources

Example script for launching an Ansible Tower job from Bitbucket Pipelines

View on

Ansible Tower CLI

Ansible Tower CLI is a command line tool and client library for Ansible Tower's REST API

Ansible Tower CLI on GitHub


Video Demo

Ansible Quick Start - Introduction to Ansible

Watch Video