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
| #!/bin/bash | |
| #5 minutes Ansible module to list groups in inventory :D | |
| #You can see outupt of script like "JSON Pretty Print" outside Ansible by using: | |
| #./listgroups | python -m json.tool | |
| inventory_file=$(awk '/^hostfile/{print $3}' /etc/ansible/ansible.cfg) | |
| groups_array=($(awk 'BEGIN {ORS=" "}; /^\[/{gsub("[\[\]]",""); print}' $inventory_file)) | |
| init_array_for_json () { | |
| for group in ${groups_array[@]}; do |
NewerOlder