Commit 48762d78 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Fix previous commit that broken queue and backlog SSH keys deployment

parent 94c1af06
......@@ -251,8 +251,11 @@ class SSHKeyDeployQueueCallback(ansible.plugins.callback.default.CallbackModule)
def v2_runner_on_ok(self, result, **kwargs):
host = result._host
username = result._result['invocation']['module_args']['user']
self.deploy_success[username].add(host.name)
# Hack to only keep tasks that actually write the SSH keys (and
# discard the tasks that simply create ~/.ssh)
if result._result['invocation']['module_args']['mode'] == '400':
username = result._result['invocation']['module_args']['owner']
self.deploy_success[username].add(host.name)
# Call the default callback (to display what's going on)
super(SSHKeyDeployQueueCallback, self).v2_runner_on_ok(result, **kwargs)
......@@ -310,12 +313,15 @@ class SSHKeyDeployBacklogCallback(ansible.plugins.callback.default.CallbackModul
def v2_runner_on_ok(self, result, **kwargs):
host = result._host
username = result._result['invocation']['module_args']['user']
if not self.test_mode:
# Remove from backlog
user = FarmUser.objects.get(username=username)
machine = Machine.objects.get(hostname=host.name)
SSHKeyDeployBacklog.objects.get(user=user, machine=machine).delete()
# Hack to only keep tasks that actually write the SSH keys (and
# discard the tasks that simply create ~/.ssh)
if result._result['invocation']['module_args']['mode'] == '400':
username = result._result['invocation']['module_args']['owner']
if not self.test_mode:
# Remove from backlog
user = FarmUser.objects.get(username=username)
machine = Machine.objects.get(hostname=host.name)
SSHKeyDeployBacklog.objects.get(user=user, machine=machine).delete()
# Call the default callback (to display what's going on)
super(SSHKeyDeployBacklogCallback, self).v2_runner_on_ok(result, **kwargs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment