Skip to content


ansible dynamic inventory from Satellite 5.8

This is a bash example (SatAnsInv.bash):

#!/bin/bash
### W.M. Duszyk 12/8/17

if [ "$1" == "--host" ]
  then
    echo '{}'
    exit 0
fi
jhosts="{"

for HostGroup in `/usr/bin/spacecmd --nossl group_list -q`
do
  jhosts="$jhosts $HostGroup: ["
  for host in `/usr/bin/spacecmd --nossl group_listsystems $HostGroup -q`
    do
        jhosts="$jhosts$host,"
    done
  jhosts=$jhosts"],"
done

jhosts="$jhosts _meta: { hostvars: {}}}"
printf "$jhosts"

To use it with all hosts registered with Satellite server:

# ansible all -i ./SatAnsInv.bash -m ping

If you have a host group defined under the name of “Unmanaged”:

# ansible Unmanaged -i ./SatAnsInv.bash -m ping

Satellite access info (its hostname, login name and password) are stored in the file ./.spacecmd/configure.

Posted in LINUX, Satellite, scripts.

Tagged with , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

WordPress Anti Spam by WP-SpamShield



Copyright © 2016 - 2018 Waldemar Mark Duszyk. All Rights Reserved. Created by Blog Copyright.