# Spacewalk as a dynamic inventory sources on remote server

**URL:** <https://forum.ansible.com/t/spacewalk-as-a-dynamic-inventory-sources-on-remote-server/17156>\
**Category:** Ansible Project\
**Created:** [December 30, 2014, 8:31am UTC](https://forum.ansible.com/t/spacewalk-as-a-dynamic-inventory-sources-on-remote-server/17156 "2014-12-30T08:31:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaclav\_Adamec](https://avatars.discourse-cdn.com/v4/letter/v/a6a055/32.png) [@Vaclav\_Adamec](https://forum.ansible.com/u/Vaclav_Adamec)\
**Post date:** [December 30, 2014, 8:31am UTC](https://forum.ansible.com/t/spacewalk-as-a-dynamic-inventory-sources-on-remote-server/17156/1 "2014-12-30T08:31:42Z")

</div>

Hi,  
most of example inventory scripts expect that service run on same server as Ansible, as this is very unlikely I use simple workaround for Spacewalk (replace SW\_REPORT with own script which calls Spacewalk server via Ansible). I would like to humbly ask for some modification of Spacewalk inventory script from some Python programmer - to allow also remote calls. I presume that anybody who use Spacewalk as a backend need this/already do such modification in better way than my hack.

Thanks for hints

Vasek

My “workaround right now”:

spacewalk.py  
SW\_REPORT = ‘/usr/local/bin/remote\_spacewalk.py’

remote\_spacewalk.py

#!/usr/bin/python

import ansible.runner  
import sys

cmdargs = str(sys.argv)

# construct the ansible runner and execute on all hosts

results = ansible.runner.Runner(  
pattern=‘spacewalk-master\*’,  
forks=1,  
remote\_user=‘ansible’,  
sudo=True,  
module\_name=‘command’,  
module\_args=“/usr/bin/spacewalk-report %s” % str(sys.argv[1]),  
).run()

if results is None:  
print “No spacewalk server found”  
sys.exit(1)

for (hostname, result) in results[‘contacted’].items():  
if not ‘failed’ in result:  
print “%s” % (result[‘stdout’])
