Skip to content

Instantly share code, notes, and snippets.

@ckelner
Last active October 5, 2020 17:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckelner/843ab1cf83efbc24e9c8bdc474753a2a to your computer and use it in GitHub Desktop.
Save ckelner/843ab1cf83efbc24e9c8bdc474753a2a to your computer and use it in GitHub Desktop.
Using the Datadog Ansible integration with Ansible Tower

Datadog and Ansible Tower

This doc explains the nuances of using the Datadog Ansible Integration with Ansible Tower.

Ansible Setup

In a directory of your choosing, run the following commands:

  • vagrant init ansible/tower
  • vagrant up --provider virtualbox
  • vagrant ssh

Upon SSH'ing into the vagrant you'll be greeted with a MOTD similar to:

Welcome to Ansible Tower!

  Log into the web interface here:

    https://10.42.0.42/

    Username: admin
    Password: <redacted>

Open up the URL provided. Enter the username and password provided. You'll then need to fill out a quick form to get a trial license key. The email arrived within ~5 minutes of filling out the form. Upload the key that was sent via email.

Datadog Integration Setup

  • Enable the integration in the Datadog Web UI.
  • Following the instructions install the following on the vagrant (a little extra work is required here because of missing packages on the vagrant):
    • curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
    • python get-pip.py
    • sudo pip install datadog

At this juncture, the user could either decide to include datadog_callback.py in every playbook in the callback_plugins directory or they can install it globally for all playbooks on the Ansible Tower server. The context of this document is to install it globally.

The Ansible Tower documentation is incorrect (as of v3.1.4 which was latest asof 2017-07-27; permalink for v3.1.4) as to where the plugin should be installed. The installation directory for datadog_callback.py, contrary to the documentation, is actually /usr/lib/python2.7/site-packages/ansible/plugins/callback.

The following command set will get the Datadog Ansible plugin setup properly:

  • cd /usr/lib/python2.7/site-packages/ansible/plugins/callback
  • curl -o datadog_callback.py https://raw.githubusercontent.com/DataDog/ansible-datadog-callback/master/datadog_callback.py
  • sudo vi datadog_callback.yml
    • insert api_key: <your-api-key> into this yaml file. Note: must be an API key not an App key

Executing Ansible Playbook and viewing Datadog Events

Use the Ansible Tower Web UI to execute a playbook: run job

Verify execution of playbook: run output

Note events in Datadog Web UI event stream: ansible events in datadog UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment