]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
task/ansible: move ansible logs to ansible.log 1678/head
authorKamoltat Sirivadhna <ksirivad@redhat.com>
Wed, 22 Sep 2021 19:26:01 +0000 (15:26 -0400)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Thu, 20 Jan 2022 00:13:45 +0000 (00:13 +0000)
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 <ksirivad@redhat.com>
teuthology/task/ansible.py
teuthology/test/task/test_ansible.py
teuthology/test/task/test_ceph_ansible.py

index 9103b357e2178fe1207a7c86293eedfdbdf84a94..94bc5d4d20dba3a432afa60a1fcd9f4ecdd5bc7b 100644 (file)
@@ -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,
         )
index ae4244dc861023c62dcc598925c7c2d76d928c72..ec426d710275ff7eac18317fb0918ae88923268c 100644 (file)
@@ -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()
 
index 2c82f6cd08fbc35abcfada35ba757444be123845..ff3b2ff6c54a613ce70e9c43a30f3b5e69b74b82 100644 (file)
@@ -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()