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.
pull/26810/head
Toshio Kuratomi 7 years ago
parent b4a58b65fb
commit e986e31a75

@ -74,13 +74,10 @@ class BaseInventoryPlugin(object):
pass pass
def populate_host_vars(self, hosts, variables, group=None, port=None): def populate_host_vars(self, hosts, variables, group=None, port=None):
for host in hosts:
if hosts: self.inventory.add_host(host, group=group, port=port)
for host in hosts: for k in variables:
self.inventory.add_host(host, group=group, port=port) self.inventory.set_variable(host, k, variables[k])
if variables:
for k in variables:
self.inventory.set_variable(host, k, variables[k])
def _compose(self, template, variables): def _compose(self, template, variables):
''' helper method for pluigns to compose variables for Ansible based on jinja2 expression and inventory vars''' ''' helper method for pluigns to compose variables for Ansible based on jinja2 expression and inventory vars'''

Loading…
Cancel
Save