From 9c498bff0f3d9f970ce2801931b2dc96cfbb318d Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 17 Jul 2015 14:01:57 -0600 Subject: [PATCH] Ansible: reconnect to remotes after playbook runs To take advantage of the updated ssh_config shipped by the testnodes role Signed-off-by: Zack Cerza --- teuthology/task/ansible.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index 405eadfb22..0d69667a3f 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -66,6 +66,10 @@ class Ansible(Task): again during teardown with a 'cleanup' var set to True. This will allow the playbook to clean up after itself, if the playbook supports this feature. + reconnect: If set to True (the default), then reconnect to hosts after + ansible-playbook completes. This is in case the playbook + makes changes to the SSH configuration, or user accounts - + we would want to reflect those changes immediately. Examples: @@ -240,6 +244,12 @@ class Ansible(Task): if status != 0: raise CommandFailedError(command, status) + if self.config.get('reconnect', True) is True: + remotes = self.cluster.remotes.keys() + log.debug("Reconnecting to %s", remotes) + for remote in remotes: + remote.reconnect() + def _build_args(self): """ Assemble the list of args to be executed -- 2.39.5