Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic inventory script throws xmlrpc.client.ProtocolError: <ProtocolError for cobbler/cobbler_api: 404 Not Found> #2348

Closed
ShrutiChavali opened this issue May 28, 2020 · 8 comments
Assignees

Comments

@ShrutiChavali
Copy link

Version

Cobbler 2.9.0
source: b'8010c5d8', b'Mon Feb 18 16:08:42 2019 +0100'
build time: Wed Feb 20 18:17:47 2019

Question

I am trying to use dynamic inventory of ansible. Copied the cobber.py script and I am trying to run the command, ./cobbler.py --list. It throws a ProtocolError.

Any help here or suggestion to run this?

@opoplawski
Copy link
Contributor

FWIW - I'm using a modified script. See ansible/ansible#25926

@ShrutiChavali
Copy link
Author

ShrutiChavali commented May 30, 2020

@opoplawski
Thanks for the script. It would help me a lot.
I have few issues while using the above script.

  1. Error: ModuleNotFoundError: No module named 'ConfigParser' (Not supported by Python3)
    --> Changed this module to 'configparser', and it works

  2. ModuleNotFoundError: No module named 'xmlrpclib' (Not supported by Python3)
    --> Changed this as " import xmlrpc.client as xmlrpclib", and it works

  3. File "/usr/lib64/python3.6/configparser.py", line 1138, in _unify_values
    sectiondict = self._sections[section]
    KeyError: 'cobbler'
    During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./cobbler.py", line 331, in
CobblerInventory()
File "./cobbler.py", line 80, in init
self.read_settings()
File "./cobbler.py", line 158, in read_settings
self.orderby_keyname = config.get('cobbler', 'orderby_keyname')
File "/usr/lib64/python3.6/configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "/usr/lib64/python3.6/configparser.py", line 1141, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'cobbler'

--> I am looking into this currently. Please let me know if you have encountered the above, and if any solution.

Thanks a lot for you help.

@opoplawski
Copy link
Contributor

Ah, sorry - I'm using a newer version in production. I'll try to get you a copy soon...

@opoplawski
Copy link
Contributor

I've pushed my latest version to https://github.com/opoplawski/ansible/tree/cobbler/contrib/inventory

I see now that I removed environment variable support and the ability to ignore the config file - hope you weren't counting on that...

@ShrutiChavali
Copy link
Author

@opoplawski
Thanks a lot for the revised script.
I tried to use the script you shared. The latest one. But I am missing out on something. Still getting this error:

File "/usr/lib64/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./cobbler.py", line 376, in
CobblerInventory()
File "./cobbler.py", line 95, in init
self.load_inventory_from_cache()
File "./cobbler.py", line 344, in load_inventory_from_cache
cache = open(self.cache_path_inventory, 'r')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/ansible-cobbler.index'

Not sure what I am missing.

@opoplawski
Copy link
Contributor

What is your cobbler.ini file?

@ShrutiChavali
Copy link
Author

ShrutiChavali commented Jun 1, 2020

I checked my cobbler.ini file. It was wrong, as in it was holding wrong host url. It works now. That helped a lot. I can see the list of my hosts.

Thanks a lot :)

@opoplawski
Copy link
Contributor

Now provided as an inventory plugin: https://github.com/cobbler/ansible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants