# cobbler external inventory script, does not seem to pick up the already existing hosts in cobbler

**URL:** <https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398>\
**Category:** Ansible Project\
**Created:** [January 22, 2014, 2:27pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398 "2014-01-22T14:27:48Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [January 22, 2014, 2:27pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/1 "2014-01-22T14:27:48Z")

</div>

Hello,

I wanted to give [“This script”](https://raw.github.com/ansible/ansible/devel/plugins/inventory/cobbler.py) (from [http://docs.ansible.com/intro\_dynamic\_inventory.html#example-the-cobbler-external-inventory-script](http://docs.ansible.com/intro_dynamic_inventory.html#example-the-cobbler-external-inventory-script)) a try to do the dynamic inventory.

Benno helped me in irc to get rid of some errors, due to not having a **cobbler.ini** in the same directory.  
_An example file can be found in /opt/ansible/plugins/inventory/cobbler.ini or in git_

_It would be nice to include that in the manual, for newbies like me_

Now I have currently 6 hosts in cobbler, but the script seems not aware of it, see output below:

**[root@geppetto ansible]# cobbler system list**  
**metop-20.oma.be**  
**metop-28.oma.be**  
**zotac-09**  
**zotac-24.oma.be**  
**zotac-29**  
**zotac-36**  
**[root@geppetto ansible]# ./cobbler.py**  
**{}**  
**[root@geppetto ansible]#**  
**[root@geppetto ansible]# cobbler --version**  
**Cobbler 2.4.0**  
**source: ?, ?**  
**build time: Thu Jun 20 06:07:51 2013**  
**[root@geppetto ansible]#**

Any ideas?  
Would it make sense if I upload the output of  
**[root@geppetto ansible]# python -mtrace --trace ./cobbler.py**  **\> cobbler.py.debuglog**

here? It is big!:  
**[root@geppetto ansible]# ls -lah cobbler.py.debuglog**  
**-rw-r–r–. 1 root root 3.4M Jan 21 15:01 cobbler.py.debuglog**  
**[root@geppetto ansible]# wc -l cobbler.py.debuglog**  
**76780 cobbler.py.debuglog**  
**[root@geppetto ansible]#**

Thanks\*\*,\*\*

Joost

BTW:  
A little note on selinux, since that is often the culprit: I have it running currently in permissive mode.  
I grepped /var/log/audit/audit.log for ansible: nothing found.  
What I found on cobbler I poured into a policy and applied it and I tried again:

**[root@geppetto ansible]# grep ansible /var/log/audit/audit.log**  
**[root@geppetto ansible]#**  
**[root@geppetto ansible]# grep cobbler /var/log/audit/audit.log**  
**type=AVC msg=audit(1390309171.088:106152): avc: denied { write } for pid=27878 comm=“httpd” name=“webui\_sessions” dev=dm-0 ino=17958021 scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=dir**  
**type=AVC msg=audit(1390309171.088:106152): avc: denied { add\_name } for pid=27878 comm=“httpd” name=“sessionid5f93d6b7217e5248218a9c705f0769cf” scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=dir**  
**type=AVC msg=audit(1390309171.088:106152): avc: denied { create } for pid=27878 comm=“httpd” name=“sessionid5f93d6b7217e5248218a9c705f0769cf” scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=file**  
**type=AVC msg=audit(1390309171.088:106152): avc: denied { write } for pid=27878 comm=“httpd” name=“sessionid5f93d6b7217e5248218a9c705f0769cf” dev=dm-0 ino=17958488 scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=file**  
**type=AVC msg=audit(1390309171.089:106153): avc: denied { remove\_name } for pid=27878 comm=“httpd” name=“sessionid5f93d6b7217e5248218a9c705f0769cf\_out\_Ud8hJk” dev=dm-0 ino=17958538 scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=dir**  
**type=AVC msg=audit(1390309171.089:106153): avc: denied { rename } for pid=27878 comm=“httpd” name=“sessionid5f93d6b7217e5248218a9c705f0769cf\_out\_Ud8hJk” dev=dm-0 ino=17958538 scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=file**  
**type=AVC msg=audit(1390309171.089:106153): avc: denied { unlink } for pid=27878 comm=“httpd” name=“sessionid5f93d6b7217e5248218a9c705f0769cf” dev=dm-0 ino=17958488 scontext=system\_u:system\_r:httpd\_t:s0 tcontext=system\_u:object\_r:cobbler\_var\_lib\_t:s0 tclass=file**  
**[root@geppetto ansible]#**

**[root@geppetto selinux]# grep cobbler /var/log/audit/audit.log | audit2allow -M cobblerpol**  
**\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* IMPORTANT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\***  
**To make this policy package active, execute:**

**semodule -i cobblerpol.pp**

**[root@geppetto selinux]# semodule -i cobblerpol.pp**  
**[root@geppetto selinux]# cd /etc/ansible**  
**[root@geppetto ansible]# ./cobbler.py**  
**{}**  
**[root@geppetto ansible]#**

But no real difference,… like it should since it is permissive mode.

---

<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:** [January 22, 2014, 3:26pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/2 "2014-01-22T15:26:59Z")

</div>

Hi Joost,

I think you might need to add --list as an argument to the script if  
you run it "stand alone".

If you want to use it with ansible or ansible-playbook you can run it  
with -i cobbler.py ( example : ansible-playbook -i cobbler.py  
\<playbook\> ).

I have no cobbler setup to test this, so I might be wrong.

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:** [January 22, 2014, 3:32pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/3 "2014-01-22T15:32:11Z")

</div>

Vincent,

You are incorrect, the default behavior is in fact the same as --list.

I’d probably recommend debugging the example inventory script or you may have an issue with their being no systems the last time the cache of the inventory was written, which is in cobbler.ini as 900 seconds.

---

<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:** [January 22, 2014, 3:51pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/4 "2014-01-22T15:51:26Z")

</div>

> Vincent,
> 
> You are incorrect, the default behavior is in fact the same as --list.

Didn't know that. I also didn't check ( my bad ).

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [January 22, 2014, 10:33pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/5 "2014-01-22T22:33:50Z")

</div>

Thanks for looking into this, Michael and Vincent.  
Alas no solution yet.  
More than 900 seconds have passed by now, but still no hosts seen with the script:

**[root@geppetto ansible]# cobbler system list**  
**metop-20.oma.be**  
**metop-28.oma.be**  
**zotac-09**  
**zotac-24.oma.be**  
**zotac-29**  
**zotac-36**  
**[root@geppetto ansible]# ./cobbler.py --list**  
**{}**  
**[root@geppetto ansible]# ./cobbler.py**  
**{}**  
**[root@geppetto ansible]# date**  
**wo jan 22 23:04:40 CET 2014**  
**[root@geppetto ansible]# cat cobbler.ini**  
**# Ansible Cobbler external inventory script settings**

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [January 22, 2014, 10:37pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/6 "2014-01-22T22:37:14Z")

</div>

Hereby some grep output as promised in previous mail:  
**[root@geppetto ansible]# grep -i error -B 2 -A 2 cobbler.py.debuglog \> errorswithsomelinesbeforeandsomeafter.log**  
**[root@geppetto ansible]# [root@geppetto ansible]# cat errorswithsomelinesbeforeandsomeafter.log**  
**argparse.py(64): version = ‘1.2.1’**  
**argparse.py(66): ‘ArgumentParser’,**  
**argparse.py(67): ‘ArgumentError’,**  
**argparse.py(68): ‘ArgumentTypeError’,**  
**argparse.py(69): ‘FileType’,**  
**argparse.py(70): ‘HelpFormatter’,**

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [January 27, 2014, 12:45pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/7 "2014-01-27T12:45:43Z")

</div>

I looked a bit further, did RTFM of cobbler, and found this:  
[https://fedorahosted.org/cobbler/wiki/CobblerXmlrpc](https://fedorahosted.org/cobbler/wiki/CobblerXmlrpc)  
Where I did a test with the included example code:

```auto

<b>#!/usr/bin/python
import xmlrpclib
server = xmlrpclib.Server("http://127.0.0.1/cobbler_api")
server = xmlrpclib.Server("http://127.0.0.1/cobbler_api")
print server.get_distros()
print server.get_profiles()
print server.get_systems()
print server.get_images()
print server.get_repos()</b>

```

This gives a lot of output, not well formatted, but I recognise what is stored in cobbler.

So imho, the cobbler\_api works, … but not the way the cobbler.py script tries present data from it.

Thanks,

Joost

---

<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:** [January 27, 2014, 1:34pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/8 "2014-01-27T13:34:34Z")

</div>

That’s curious.

I wrote that script against a live Cobbler install and we’ve got users using it in the wild.

Unfortunately, this isn’t something we really have time to troubleshoot here. It is something that we’d help support customers with, but it involves replicating and digging inside of your Cobbler setup, so it’s a bit out of scope for ansible-project’s mailing list.

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [February 4, 2014, 8:52am UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/9 "2014-02-04T08:52:32Z")

</div>

Hi Michael,

That’s really no problem. I just wanted to give it a go since it was in the tutorial.  
Thanks for looking into it anyway.

I am glad I am now on [http://cfgmgmtcamp.eu/](http://cfgmgmtcamp.eu/) , the tutors here are great, I am learning a lot here.

Joost

---

<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:** [February 4, 2014, 9:02am UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/10 "2014-02-04T09:02:18Z")

</div>

I'm about to test cobbler to. I might have a look when I find the time.

Maybe later in the afternoon at cgmgmntcamp.

Vincent

---

<div class="post-metadata">

**Author:** ![Wouter\_Jagers](https://avatars.discourse-cdn.com/v4/letter/w/e9c0ed/32.png) [@Wouter\_Jagers](https://forum.ansible.com/u/Wouter_Jagers)\
**Post date:** [February 8, 2014, 11:07pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/11 "2014-02-08T23:07:14Z")

</div>

Hi Joost,

I just spent some time digging for the same. Turns out that my existing systems did not have “management” set and were therefore not included in the results.

Should this be the case, you should start getting output after issuing one of these:

# cobbler system edit --name=somenode --management=yes

Cheers  
Wouter

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [February 11, 2014, 3:17pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/12 "2014-02-11T15:17:16Z")

</div>

Hi Wouter,

Thank you for looking into this and sharing your findings Wouter.  
Good to hear that enabling management fixed it for you.  
Alas for me that’s not the case.

[root@geppetto ansible]# cobbler system list  
metop-20.oma.be  
metop-28.oma.be  
zotac-09  
zotac-24.oma.be  
zotac-29  
zotac-36  
[root@geppetto ansible]#  
[root@geppetto ansible]# ./cobbler.py  
{}  
[root@geppetto ansible]# cobbler system edit --name=zotac-29 --management=yes  
[root@geppetto ansible]# ./cobbler.py  
{}

Whereas the api still works, because the following line gives lots of output (too much to be readable):

[root@geppetto ansible]# ./cobblerdemo.py | grep zotac-29

and this being the contents:  
[root@geppetto ansible]# cat ./cobblerdemo.py  
#!/usr/bin/python  
import xmlrpclib  
server = xmlrpclib.Server(“[http://127.0.0.1/cobbler\_api](http://127.0.0.1/cobbler_api)”)  
server = xmlrpclib.Server(“[http://127.0.0.1/cobbler\_api](http://127.0.0.1/cobbler_api)”)  
print server.get\_systems()  
[root@geppetto ansible]#

Cheers,

Joost

---

<div class="post-metadata">

**Author:** ![Tomasz\_Lesniewski](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@Tomasz\_Lesniewski](https://forum.ansible.com/u/Tomasz_Lesniewski)\
**Post date:** [March 7, 2014, 2:26pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/13 "2014-03-07T14:26:16Z")

</div>

It is required to have filled both “management interface” and “dns name” (for the same interface if you have more than one).

W dniu wtorek, 11 lutego 2014 16:17:16 UTC+1 użytkownik Joost Ringoot napisał:

---

<div class="post-metadata">

**Author:** ![Joost\_Ringoot](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Joost\_Ringoot](https://forum.ansible.com/u/Joost_Ringoot)\
**Post date:** [March 17, 2014, 2:23pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/14 "2014-03-17T14:23:45Z")

</div>

With help of Wouter Jagers, the script now picks up the systems installed by cobbler.  
I needed to perform something like this for the hosts

cobbler system edit --name=$COBBLERHOSTNAME --dns-name=$FQDN --management=true

Thanks Wouter.  
Thanks also to Michael for all your enormous work for the community.  
Thanks also to Vincent and Tomasz and others I might forget.

---

<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:** [March 17, 2014, 2:51pm UTC](https://forum.ansible.com/t/cobbler-external-inventory-script-does-not-seem-to-pick-up-the-already-existing-hosts-in-cobbler/14398/15 "2014-03-17T14:51:23Z")

</div>

IIRC, the management=true stuff is after my time with the project.

IMHO, the inventroy script shouldn’t care about this, but it may be something on the API side that was not returning something.
