Created
January 6, 2021 01:22
-
-
Save aspen-roller/a293d9c45fa835d1307a2c0fc923617c to your computer and use it in GitHub Desktop.
query node.js version #ansible #util
This file contains hidden or 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
# ensure JSON output with ANSIBLE_STDOUT_CALLBACK | |
# remove all lines before the first '{' | |
# remove all lines after the last '}' | |
# use jq to query the stdout value from the command | |
# ASSUMPTION | |
# there is a group "services" that identifies machines with node.js installed | |
ANSIBLE_STDOUT_CALLBACK=json ansible services -i inventories/dev -m command -a 'node --version' -v | sed '1,/^[^{]/d' | sed '/^}/q' | jq -r '.plays[].tasks[].hosts | keys[] as $k | "\($k): \(.[$k] | .stdout)"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment