diff --git a/changelogs/fragments/638_cobbler_py3.yml b/changelogs/fragments/638_cobbler_py3.yml new file mode 100644 index 0000000000..18e18d1841 --- /dev/null +++ b/changelogs/fragments/638_cobbler_py3.yml @@ -0,0 +1,2 @@ +bugfixes: +- cobbler - add Python 3 support (https://github.com/ansible-collections/community.general/issues/638). diff --git a/scripts/inventory/cobbler.py b/scripts/inventory/cobbler.py index 84d594720e..eeb8f58286 100644 --- a/scripts/inventory/cobbler.py +++ b/scripts/inventory/cobbler.py @@ -52,7 +52,10 @@ import argparse import os import re from time import time -import xmlrpclib +try: # Python 3 + from xmlrpc.client import Server +except ImportError: # Python 2 + from xmlrpclib import Server import json @@ -106,7 +109,7 @@ class CobblerInventory(object): def _connect(self): if not self.conn: - self.conn = xmlrpclib.Server(self.cobbler_host, allow_none=True) + self.conn = Server(self.cobbler_host, allow_none=True) self.token = None if self.cobbler_username is not None: self.token = self.conn.login(self.cobbler_username, self.cobbler_password)