Rotate ansible.log during ceph deploy
'overcloud ceph deploy' logs are redirected to /home/stack/ansible.log. Before python-tripleo-client runs cephadm playbook, check if the log file ansible.log exists (from a previous run). If it does, then rename it to append a timestamp. When cephadm is run,a new log will be created. A new parameter 'rotate_log=False' is added to run_ansible_playbook function which can be enabled for any other operations to perform log rotation. Change-Id: I13bf6c6377ac049054c22d0b8a0e005366c44b7f Resolves: rhbz#2149339 (cherry picked from commit6e7c8c35aa
) (cherry picked from commit732c126000
)
This commit is contained in:
parent
a635ebadee
commit
f7df028e09
|
@ -362,6 +362,7 @@ class TestOvercloudCephSpec(fakes.FakePlaybookExecution):
|
|||
verbosity=3,
|
||||
tags='ceph_spec',
|
||||
reproduce_command=False,
|
||||
rotate_log=True,
|
||||
extra_vars={
|
||||
"baremetal_deployed_path": mock.ANY,
|
||||
'tripleo_roles_path': mock.ANY,
|
||||
|
|
|
@ -256,7 +256,7 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||
ansible_cfg=None, ansible_timeout=30,
|
||||
reproduce_command=False,
|
||||
timeout=None, forks=None,
|
||||
ignore_unreachable=False):
|
||||
ignore_unreachable=False, rotate_log=False):
|
||||
"""Simple wrapper for ansible-playbook.
|
||||
|
||||
:param playbook: Playbook filename.
|
||||
|
@ -349,6 +349,9 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||
|
||||
:param timeout: Timeout for ansible to finish playbook execution (minutes).
|
||||
:type timeout: int
|
||||
|
||||
:param rotate_log: Enable or disable option to rotate ansible.log
|
||||
:type rotate_log: Boolean
|
||||
"""
|
||||
|
||||
def _playbook_check(play):
|
||||
|
@ -661,6 +664,9 @@ def run_ansible_playbook(playbook, inventory, workdir, playbook_dir=None,
|
|||
if parallel_run:
|
||||
r_opts['directory_isolation_base_path'] = ansible_artifact_path
|
||||
|
||||
if rotate_log and os.path.exists(env['ANSIBLE_LOG_PATH']):
|
||||
rotate_ansible_log(env['ANSIBLE_LOG_PATH'])
|
||||
|
||||
runner_config = ansible_runner.runner_config.RunnerConfig(**r_opts)
|
||||
runner_config.prepare()
|
||||
# NOTE(cloudnull): overload the output callback after prepare
|
||||
|
@ -3361,3 +3367,9 @@ def get_output_dir(output_dir: str, stack_name: str = "undercloud") -> str:
|
|||
return os.path.join(constants.UNDERCLOUD_OUTPUT_DIR,
|
||||
'tripleo-deploy', stack_name)
|
||||
return output_dir
|
||||
|
||||
|
||||
def rotate_ansible_log(ansible_log_abspath):
|
||||
now = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
|
||||
new_ansible_log_abspath = os.path.join(ansible_log_abspath+"-"+now)
|
||||
os.rename(ansible_log_abspath, new_ansible_log_abspath)
|
||||
|
|
|
@ -1116,4 +1116,5 @@ class OvercloudCephSpec(command.Command):
|
|||
extra_vars=extra_vars,
|
||||
reproduce_command=False,
|
||||
tags=tags,
|
||||
rotate_log=True,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue