Skip to content

Instantly share code, notes, and snippets.

View aabouzaid's full-sized avatar
🐧
I enjoy facilitating the growth of both businesses and individuals!

Ahmed AbouZaid aabouzaid

🐧
I enjoy facilitating the growth of both businesses and individuals!
View GitHub Profile
#!/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