From 685607d0f96f172c2992b9859e1f6024952f1e3f Mon Sep 17 00:00:00 2001 From: Kamoltat Sirivadhna Date: Wed, 22 Sep 2021 15:26:01 -0400 Subject: [PATCH] task/ansible: move ansible logs to ansible.log Currently ansible tasks are logging to teuthology.log. We want to separate this to it's own log files for better readability. Signed-off-by: Kamoltat Sirivadhna --- teuthology/task/ansible.py | 9 +++++---- teuthology/test/task/test_ansible.py | 1 + teuthology/test/task/test_ceph_ansible.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index 9103b357e2..94bc5d4d20 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -15,8 +15,8 @@ from teuthology.repo_utils import fetch_repo from teuthology.task import Task -log = logging.getLogger(__name__) - +log = logging.Logger(__name__) +log.setLevel(logging.INFO) class LoggerFile(object): """ @@ -115,6 +115,8 @@ class Ansible(Task): self.log = log self.generated_inventory = False self.generated_playbook = False + log.addHandler(logging.FileHandler(os.path.join(ctx.archive, + "ansible.log"))) def setup(self): super(Ansible, self).setup() @@ -278,11 +280,10 @@ class Ansible(Task): command = ' '.join(args) log.debug("Running %s", command) - out_log = self.log.getChild('out') out, status = pexpect.run( command, cwd=self.repo_path, - logfile=_logfile or LoggerFile(out_log, logging.INFO), + logfile=_logfile or LoggerFile(log, logging.INFO), withexitstatus=True, timeout=None, ) diff --git a/teuthology/test/task/test_ansible.py b/teuthology/test/task/test_ansible.py index ae4244dc86..ec426d7102 100644 --- a/teuthology/test/task/test_ansible.py +++ b/teuthology/test/task/test_ansible.py @@ -33,6 +33,7 @@ class TestAnsibleTask(TestTask): self.ctx.cluster.add(Remote('user@remote2'), ['role2']) self.ctx.config = dict() self.ctx.summary = dict() + self.ctx.archive = '../' self.task_config = dict(playbook=[]) self.start_patchers() diff --git a/teuthology/test/task/test_ceph_ansible.py b/teuthology/test/task/test_ceph_ansible.py index 2c82f6cd08..ff3b2ff6c5 100644 --- a/teuthology/test/task/test_ceph_ansible.py +++ b/teuthology/test/task/test_ceph_ansible.py @@ -29,6 +29,7 @@ class TestCephAnsibleTask(TestTask): self.ctx.cluster.add(Remote('user@remote3'), ['osd.0']) self.ctx.summary = dict() self.ctx.config = dict() + self.ctx.archive = '../' self.task_config = dict() self.start_patchers() -- 2.39.5