diff --git a/changelogs/fragments/drop-host-api-fallback.yml b/changelogs/fragments/drop-host-api-fallback.yml new file mode 100644 index 0000000000..1624517cc3 --- /dev/null +++ b/changelogs/fragments/drop-host-api-fallback.yml @@ -0,0 +1,2 @@ +bugfixes: + - inventory - Drop fallback to Host API when Reports API fails, as this leads to possibly wrong data being used diff --git a/plugins/inventory/foreman.py b/plugins/inventory/foreman.py index 076bf21718..459196141f 100644 --- a/plugins/inventory/foreman.py +++ b/plugins/inventory/foreman.py @@ -474,13 +474,10 @@ def _get_hostname(self, properties, hostnames, strict=False): def _populate_report_api(self): self.groups = dict() self.hosts = dict() - try: - # We need a deep copy of the data, as we modify it below and this would also modify the cache - host_data = copy.deepcopy(self._post_request()) - except Exception as exc: - self.display.warning("Failed to use Reports API, falling back to Hosts API: {0}".format(exc)) - self._populate_host_api() - return + + # We need a deep copy of the data, as we modify it below and this would also modify the cache + host_data = copy.deepcopy(self._post_request()) + self.group_prefix = self.get_option('group_prefix') hostnames = self.get_option('hostnames')