Quick'n'dirty hack: ansible inventory from FreeIPA
If the ansible inventory file is +x
, it will be executed. Simplest way to reach all hosts registered in FreeIPA:
#!/bin/bash COMMA="" echo -n '{ "servers" : [' for srv in $(LC_ALL=C ipa host-find --not-in-hostgroup=non-servers | awk '/Host name:/{print $3}'); do echo -n $COMMA if [ -e $COMMA ]; then COMMA=', ' fi echo -n \"$srv\" done echo '] }'
Works for now, but real solution requires --list
switch, grouping etc.
Archived comments:
zdz 2013-12-14 14:50:38
The real deal is here: https://github.com/zdzichu/trinkets/blob/master/ansible-freeipa-inventory.py
Comments
Comments powered by Disqus