Skip to content

Instantly share code, notes, and snippets.

@mbaldessari
Created October 21, 2020 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbaldessari/1491f1a03ad136ba75f5d351ebb40af8 to your computer and use it in GitHub Desktop.
Save mbaldessari/1491f1a03ad136ba75f5d351ebb40af8 to your computer and use it in GitHub Desktop.
collect sosreports
#!/bin/bash
set -e
cd /home/stack
source ./stackrc
if [ ! -f inv.yml ]; then
tripleo-ansible-inventory --static-yaml-inventory inv.yml
fi
cat > /tmp/sosreport.yml <<EOF
---
- hosts: overcloud
gather_facts: false
tasks:
- name: Create local sosreports folder
file:
path: /home/stack/sosreports
state: directory
delegate_to: localhost
- name: Collect sosreports
become: yes
shell: "sosreport --batch"
register: _create_sosreport
async: 1200 # 20 minutes max
poll: 0
- name: Wait for sosreport generation to finish
become: yes
async_status:
jid: "{{ _create_sosreport.ansible_job_id }}"
register: _jobs
until: _jobs.finished
delay: 10 # Check every 10 seconds
retries: 120 # Retry up to 120 times
- name: Get sosreports
become: yes
synchronize:
mode: pull
src: /var/tmp/sos*xz
dest: /home/stack/sosreports
EOF
ansible-playbook -i inv.yml /tmp/sosreport.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment