Integrations
Ansible
Automatically log changes to ChangeVault from your Ansible playbooks.
Overview
Use Ansible's built-in uri module to POST a change to ChangeVault at the end of a play. The API key is stored in ansible-vault so it never appears in plaintext in your repository.
Setup
1. Store the API key in ansible-vault
ansible-vault encrypt_string 'cvk_prod_••••••••' --name 'changevault_api_key'Paste the output into your group_vars/all.yml or a dedicated vault file.
2. Add the task to your playbook
- name: Log change to ChangeVault
uri:
url: "https://app.changevault.dev/api/changes"
method: POST
headers:
x-api-key: "{{ changevault_api_key }}"
Content-Type: "application/json"
body_format: json
body:
title: "{{ changevault_title | default('Ansible: ' + playbook_dir | basename + ' on ' + inventory_hostname) }}"
risk_level: "low"
status: "completed"
tags:
- ansible
- "{{ inventory_hostname }}"
status_code: 201
no_log: trueAlways set no_log: true on the ChangeVault task to prevent the API key from appearing in Ansible output or logs.
Full playbook example
---
- name: Deploy application
hosts: webservers
become: true
vars:
app_version: "3.1.0"
changevault_title: "Deployed app v{{ app_version }} on {{ inventory_hostname }}"
tasks:
- name: Pull latest release
git:
repo: "https://github.com/your-org/your-app.git"
dest: /opt/app
version: "v{{ app_version }}"
- name: Restart service
systemd:
name: your-app
state: restarted
- name: Log deployment to ChangeVault
uri:
url: "https://app.changevault.dev/api/changes"
method: POST
headers:
x-api-key: "{{ changevault_api_key }}"
Content-Type: "application/json"
body_format: json
body:
title: "{{ changevault_title }}"
description: "Host: {{ inventory_hostname }}\nVersion: {{ app_version }}"
risk_level: "low"
status: "completed"
tags:
- ansible
- deploy
- "{{ inventory_hostname }}"
status_code: 201
no_log: trueUseful Ansible variables
| Variable | Description |
|---|---|
inventory_hostname | Current host being configured |
ansible_user | User running the playbook |
playbook_dir | Directory of the playbook file |
ansible_date_time.iso8601 | Current timestamp |
API access requires the Pro plan or higher.