name = 'ceph_ansible'
# TODO: Eventually, we should drop _default_playbook in favor of site.yml.sample from ceph-ansible.git
_default_playbook = [
- # Run gather facts at the top as required by mgr-role
+ # Run gather facts at the top as required by mgr-role
dict(
hosts='all',
become=True,
os.remove(self.inventory)
os.remove(self.playbook_file)
os.remove(self.extra_vars_file)
+ # collect logs
+ self.collect_logs()
# run purge-cluster that teardowns the cluster
args = [
'ANSIBLE_STDOUT_CALLBACK=debug',
]
)
+ def collect_logs(self):
+ ctx = self.ctx
+ if ctx.archive is not None and \
+ not (ctx.config.get('archive-on-error') and ctx.summary['success']):
+ # collect logs
+ log.info('Compressing logs...')
+ run.wait(
+ ctx.cluster.run(
+ args=[
+ 'sudo',
+ 'find',
+ '/var/log/ceph',
+ '-name',
+ '*.log',
+ '-print0',
+ run.Raw('|'),
+ 'sudo',
+ 'xargs',
+ '-0',
+ '--no-run-if-empty',
+ '--',
+ 'gzip',
+ '--',
+ ],
+ check_status=False,
+ ),
+ )
+
+ log.info('Archiving logs...')
+ path = os.path.join(ctx.archive, 'remote')
+ os.makedirs(path)
+ for remote in ctx.cluster.remotes.iterkeys():
+ sub = os.path.join(path, remote.shortname)
+ os.makedirs(sub)
+ misc.pull_directory(remote, '/var/log/ceph',
+ os.path.join(sub, 'log'))
+
def wait_for_ceph_health(self):
with contextutil.safe_while(sleep=15, tries=6,
action='check health') as proceed: