# Using Spacewalk or Red Hat Satellite - new inventory script

**URL:** <https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [May 22, 2013, 1:21pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845 "2013-05-22T13:21:43Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [May 27, 2013, 4:18pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/21 "2013-05-27T16:18:42Z")

</div>

I also think that this script can only used on a spacewalk server.  
I would prefer to use the native rhn api instead.

Vincent

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 27, 2013, 8:19pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/22 "2013-05-27T20:19:46Z")

</div>

We merged it in last week, so there’s hardly anyone to break.

I think it’s fine if it requires configuration, in fact, it seems it should require an INI for the spacewalk server anyway 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 27, 2013, 8:20pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/23 "2013-05-27T20:20:16Z")

</div>

Yes, definitely.

It should at least degrade nicely if there is some new hotness that is not yet in a released Satellite server.

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [May 27, 2013, 8:48pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/24 "2013-05-27T20:48:11Z")

</div>

I'll rewrite it (remove some of the items I never finished) and do a new pull-request.

What about having an option to regenerate the whole cache (all host info) in the standard options of inventories ? The aim is to have a single option to invalidate and renew the cache from a cronjob.

PS Could we not use the ansible.cfg for inventory options as a default ?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 27, 2013, 9:06pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/25 "2013-05-27T21:06:37Z")

</div>

Cache invalidation can more or less be a convention, yes. We should stick with the parameter that the ec2 module adds now, and add more if need be.

There’s nothing in ansible that needs to know about those flags to make it a requirement, but obviously calling it with shell is ok.

I don’t think ansible.cfg is necc. ideal in the sense that you might want to use multiple inventory sources (like two different ec2 INI’s) at different times (say stage vs prod? or different customers in a MSP or hosted arrangement?), so in that case, you might have two different INI files.

–Michael

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [May 27, 2013, 9:32pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/26 "2013-05-27T21:32:00Z")

</div>

A solution could be that the inventory-script's name should match the section name in the config, e.g. spacewalk.py will look for section [inventory:spacewalk] and rhn.py will look for section [inventory:rhn].

Just an idea to avoid having to modify inventory scripts (even if only to change the config-file to use).

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 27, 2013, 10:58pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/27 "2013-05-27T22:58:27Z")

</div>

Yeah, I don’t really care for that, I don’t think.

Renaming the script would be somewhat awkward and then the script would have to look at argv[0] to decide the section name, which would be confusing to have to explain to everyone I think.

Maybe I’m wrong though, but I’d like things, because they do not already do this, to remain consistent.

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [May 28, 2013, 12:38pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/28 "2013-05-28T12:38:39Z")

</div>

> > Someone was nice enough to send a contributing to the project, so pull  
> > requests should be send to ansible's main project.
> > 
> > There is no reason to have a seperate repo for this when we already have  
> > lots of great inventory modules in core.
> 
> The difference is that the original inventory script does not require any  
> configuration (as it uses spacewalk-report) whereas if I would add my stuff  
> to it, it requires configuration directives to work.

You mean adding rhn? How are you going to make the distinction between  
spacewalk-report and using the rhn-api?

Vincent

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 28, 2013, 12:45pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/29 "2013-05-28T12:45:20Z")

</div>

Well, I really meant Satellite. But if it works with RHN too, great.

One should be able to talk to the API endpoint and figure out what you are talking to.  
I’d hope.

That all being said, if it just uses the RHN API, isn’t that fine? I think it would be.

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [May 28, 2013, 12:56pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/30 "2013-05-28T12:56:11Z")

</div>

> Well, I really meant Satellite. But if it works with RHN too, great.
> 
> One should be able to talk to the API endpoint and figure out what you are  
> talking to.  
> I'd hope.
> 
> That all being said, if it just uses the RHN API, isn't that fine? I think  
> it would be.

As far as I understand, the current inventory script uses a wrapper script  
to get info from a satellite server, but can only be run on a satellite server  
(correct me if i'm wrong).  
The inventory script is not talking to the api itself...

Vincent

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 28, 2013, 6:10pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/31 "2013-05-28T18:10:39Z")

</div>

Yes, I’m suggesting to merge dag’s ideas and this one, or maybe we should just replace it with Dag’s, if that gets us RHN and deployed Satellite support.

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [May 28, 2013, 6:47pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/32 "2013-05-28T18:47:41Z")

</div>

Ok.

I’m going to test Dag’s script

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [May 28, 2013, 8:48pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/33 "2013-05-28T20:48:31Z")

</div>

Just tested Dag's script but ran into some problems

- I think it's not compatible with the latest RHN api. ( listSystems  
-\> listUserSystems )  
- sysid must be integer and not a string ( int(system['id'] )  
- all returned groups contain the same (all) hosts. haven't looked into this.

Vincent

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 29, 2013, 11:33am UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/34 "2013-05-29T11:33:03Z")

</div>

Since the RHN API is XMLRPC you should be able to do listMethods on the top level to see what functions it supports.

Unless it’s not Python XMLRPC. That’s a non-standard method.

Though this does tend to imply it should be importing into a database instead, so it’s easier to lookup later, or at least caching very very smartly 🙂

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [May 29, 2013, 12:09pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/35 "2013-05-29T12:09:11Z")

</div>

Vincent,

It works in our infrastructure using RHN Satellite 5.5.0 (the latest IMO).

---

<div class="post-metadata">

**Author:** ![Vincent\_Van\_der\_Kuss](https://avatars.discourse-cdn.com/v4/letter/v/7c8e57/32.png) [@Vincent\_Van\_der\_Kuss](https://forum.ansible.com/u/Vincent_Van_der_Kuss)\
**Post date:** [May 29, 2013, 12:34pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/36 "2013-05-29T12:34:52Z")

</div>

> > Just tested Dag's script but ran into some problems
> > 
> > - I think it's not compatible with the latest RHN api. ( listSystems  
> > -\> listUserSystems )  
> > - sysid must be integer and not a string ( int(system['id'] )  
> > - all returned groups contain the same (all) hosts. haven't looked into  
> > this.
> 
> Vincent,
> 
> It works in our infrastructure using RHN Satellite 5.5.0 (the latest IMO).

Dag,

I'm connecting to RHN (rhn.redhat.com) and yields the same errors I  
had with my own  
scripts connecting to it.  
Weird....

Anyway, see you at the meetup. Maybe I can show you

---

<div class="post-metadata">

**Author:** ![Tracy\_Phillips](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@Tracy\_Phillips](https://forum.ansible.com/u/Tracy_Phillips)\
**Post date:** [May 19, 2014, 11:02am UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/37 "2014-05-19T11:02:16Z")

</div>

Is there a script available that will connect to our Spacewalk server from our Ansible server (using an api) to get the host/group information?

Thanks,

Tracy

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 19, 2014, 7:49pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/38 "2014-05-19T19:49:57Z")

</div>

Yes, in the source tar (or from github) there is plugins/inventory/spacewalk.py.

---

<div class="post-metadata">

**Author:** ![Tracy\_Phillips](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@Tracy\_Phillips](https://forum.ansible.com/u/Tracy_Phillips)\
**Post date:** [May 21, 2014, 4:53pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/39 "2014-05-21T16:53:56Z")

</div>

Hi James,

Unless I am missing something spacewalk.py needs to be executed on the spacewalk server, not the ansible server, correct?

Thanks,

Tracy

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 21, 2014, 10:19pm UTC](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845/40 "2014-05-21T22:19:27Z")

</div>

It does use the spacewalk-reports package. I honestly don’t know if you can configure it to point at a remote server.

It presumes you are running Ansible from the spacewalk server if you can’t - but there’s also a REST API for Satellite/Spacewalk, so I imagine alternatives could also be built fairly easily.

The documentation on the Spacewalk/Satellite API was sufficient for me to get a authentication plugin for Cobbler going with a live server, and I’m sure Red Hat might also be able to help with questions.

[Previous page](https://forum.ansible.com/t/using-spacewalk-or-red-hat-satellite-new-inventory-script/12845.md?page=1)
