From eb53f3c1298c305e6eb094dde1bade2f3bd067ff Mon Sep 17 00:00:00 2001 From: Eric L Date: Wed, 31 May 2017 22:35:28 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20inventory=20script=20for=20Foreman=20wher?= =?UTF-8?q?e=20group=20by=20pattern=20are=20not=20prope=E2=80=A6=20(#25173?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix inventory script for Foreman where group by pattern are not properly safe-guarded. * Fix pep8 error about tab mixed with blanks. --- contrib/inventory/foreman.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/contrib/inventory/foreman.py b/contrib/inventory/foreman.py index 52c19dce419..e0ca11a21df 100755 --- a/contrib/inventory/foreman.py +++ b/contrib/inventory/foreman.py @@ -262,12 +262,9 @@ class ForemanInventory(object): # Ansible groups by parameters in host groups and Foreman host # attributes. - groupby = copy.copy(params) - for k, v in host.items(): - if isinstance(v, str): - groupby[k] = self.to_safe(v) - elif isinstance(v, int): - groupby[k] = v + groupby = dict() + for k, v in params.items(): + groupby[k] = self.to_safe(str(v)) # The name of the ansible groups is given by group_patterns: for pattern in self.group_patterns: