From e986e31a75888c3eeee01fce6d3bfc78d5812e3c Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 13 Jul 2017 20:15:13 -0700 Subject: [PATCH] This function is for setting variables on hosts. So those two parts are always required. Don't have to check for the existence of those in the function. If they aren't set to iterables then it should be up to the calling code to handle it. --- lib/ansible/plugins/inventory/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/ansible/plugins/inventory/__init__.py b/lib/ansible/plugins/inventory/__init__.py index fd76165cd4..ddad67861f 100644 --- a/lib/ansible/plugins/inventory/__init__.py +++ b/lib/ansible/plugins/inventory/__init__.py @@ -74,13 +74,10 @@ class BaseInventoryPlugin(object): pass def populate_host_vars(self, hosts, variables, group=None, port=None): - - if hosts: - for host in hosts: - self.inventory.add_host(host, group=group, port=port) - if variables: - for k in variables: - self.inventory.set_variable(host, k, variables[k]) + for host in hosts: + self.inventory.add_host(host, group=group, port=port) + for k in variables: + self.inventory.set_variable(host, k, variables[k]) def _compose(self, template, variables): ''' helper method for pluigns to compose variables for Ansible based on jinja2 expression and inventory vars'''