Created
April 9, 2020 13:16
-
-
Save ssbarnea/2612f4fff99443fe934412bd34e36cb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
- hosts: localhost | |
gather_facts: no | |
tasks: | |
- vars: | |
data: | |
system: | |
df: | |
cmd: df -a | |
mem: | |
cmd: mem | |
hw: | |
pci: | |
cmd: lspci | |
debug: | |
msg: | | |
{{ data | json_query('*.*') }} | |
# TODO: category (system, hw) must be also added to each dictionary | |
# TODO: command name (2nd dic key), must be also added to each dicitonary | |
# TODO: flatten the nested list | |
# Current output: | |
# "msg": [ | |
# [ | |
# { | |
# "cmd": "df -a" | |
# }, | |
# { | |
# "cmd": "mem" | |
# } | |
# ], | |
# [ | |
# { | |
# "cmd": "lspci" | |
# } | |
# ] | |
# ] | |
# Desired output: | |
# - cmd: "df-a" | |
# group: system | |
# name: df | |
# ... | |
# Resources: | |
# https://jmespath.org/tutorial.html | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment