Skip to content

Instantly share code, notes, and snippets.

@flavono123
Last active March 24, 2022 08:01
Show Gist options
  • Save flavono123/65522ea36a1c957c74daac0dd99c8180 to your computer and use it in GitHub Desktop.
Save flavono123/65522ea36a1c957c74daac0dd99c8180 to your computer and use it in GitHub Desktop.
Ansible Ad-hoc command outputs as JSON
# module output JSON + "ansible_host" and "success" fields
$ <ansible_ad_hoc_command> | sed -E 's/(.*) \| FAILED\! \=> \{/\{"ansible_host": "\1", "success": false,/;
s/(.*) \| SUCCESS \=> \{/\{"ansible_host": "\1", "success": true,/' | jq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment