Skip to content

Instantly share code, notes, and snippets.

@ceving
Last active January 30, 2017 16:36
Show Gist options
  • Save ceving/c673c791f90d64439ab6923875f5a97f to your computer and use it in GitHub Desktop.
Save ceving/c673c791f90d64439ab6923875f5a97f to your computer and use it in GitHub Desktop.
Fix Ansible to talk JSON
#! /bin/bash
##
## This converts the output of the `ansible` command into valid JSON,
## which can be processed by `jq`.
##
echo \[
sed 's/^\(.*\) | \(.*\) => {/{\n "hostname": "\1",\n "result": "\2",/' |
sed '$ ! s/^}/},/'
echo \]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment