1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Avoid a traceback when using accelerate

This bit of code is attempting to access accelerate_inventory_host,
which may not have been set/created. This will cause a traceback.
Instead use getattr with a fallback to False.
This commit is contained in:
Jesse Keating 2013-11-27 13:58:11 -08:00
parent 12ed39ef7b
commit 5522d489e3

View file

@ -86,7 +86,7 @@ class Connection(object):
def _execute_accelerate_module(self): def _execute_accelerate_module(self):
args = "password=%s port=%s debug=%d ipv6=%s" % (base64.b64encode(self.key.__str__()), str(self.accport), int(utils.VERBOSITY), self.runner.accelerate_ipv6) args = "password=%s port=%s debug=%d ipv6=%s" % (base64.b64encode(self.key.__str__()), str(self.accport), int(utils.VERBOSITY), self.runner.accelerate_ipv6)
inject = dict(password=self.key) inject = dict(password=self.key)
if self.runner.accelerate_inventory_host: if getattr(self.runner, 'accelerate_inventory_host', False):
inject = utils.combine_vars(inject, self.runner.inventory.get_variables(self.runner.accelerate_inventory_host)) inject = utils.combine_vars(inject, self.runner.inventory.get_variables(self.runner.accelerate_inventory_host))
else: else:
inject = utils.combine_vars(inject, self.runner.inventory.get_variables(self.host)) inject = utils.combine_vars(inject, self.runner.inventory.get_variables(self.host))