tripleo-upgrade/templates/collect_logs.yaml.j2

140 lines
5.0 KiB
Django/Jinja

---
- hosts: allovercloud,Undercloud
gather_facts: false
become: true
tasks:
- name: ensure extra directory is present
file:
name: /var/log/extra
state: directory
owner: root
group: root
mode: 0755
- name: capture date at this stage
shell: |
date '+%Y-%m-%d %H:%M:%S%z' &>> /var/log/extra/date-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: save packages list at this stage
shell: |
dnf list installed &>> /var/log/extra/packages-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get podman container state at this stage
vars:
f_open: '{% raw %}{{"{{"}}{% endraw %}'
f_close: '{% raw %}{{"}}"}}{% endraw %}'
shell: |
podman ps --format {% raw %}"{{ f_open }}.Names{{ f_close }} {{ f_open }}.ID{{ f_close }} {{ f_open }}.Image{{ f_close }}"{% endraw %} | sort &>> /var/log/extra/container-ps-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get podman images state at this stage
shell: |
podman images &>> /var/log/extra/container-images-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get process list at this stage
shell: |
ps fauxwww &>> /var/log/extra/ps-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get systemd information at this stage
shell: |
systemctl list-units --all --no-pager &>> /var/log/extra/systemctl-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get cgroup information at this stage
shell: |
systemd-cgls &>> /var/log/extra/cgroups-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get release state at this stage
shell: |
for i in rhosp redhat; do
if [ ! -e /etc/${i}-release ]; then
cat /etc/${i}-release &>> /var/log/extra/release-{% raw %}{{ current_stage }}{% endraw %}.txt
fi
done
- name: get container files and test container images update
block:
- name: get all logs files related to container
find:
paths: "/var/log/extra/"
patterns: 'container-ps-before_*.txt'
excludes: "{% raw %}{{ 'undercloud' in inventory_hostname | ternary(null, 'container-ps-before_undercloud*') }}{% endraw %}"
register: found_files
- name: get the oldest file related to container states
set_fact:
latest_log: "{% raw %}{{ found_files.files | sort(attribute='mtime') | first }}{% endraw %}"
- name: create grep string for containers excluded from test
set_fact:
grep_exclude: "{% raw %}| grep -v -e {{ containers_check_excluded|split(',')|join(' -e ') }}{% endraw %}"
when: containers_check_excluded != ""
- name: check if podman images are updated before reboot
shell: "comm --nocheck-order -12 /var/log/extra/container-ps-before_reboot.txt {% raw %}{{ latest_log.path }} {{ grep_exclude|default('') }}{% endraw %}"
register: comm_result
failed_when: comm_result.rc >= 2
- name: not all podman images updated
fail:
msg: "Not all images updated"
when: comm_result.stdout != ""
when:
- current_stage == "before_reboot"
- not {{ tripleo_ci|bool }}
always:
- name: container images comparison result
debug:
var: comm_result.stdout
- hosts: ceph_mon
gather_facts: false
become: true
run_once: true
tasks:
- name: get ceph health status
shell: |
cephadm shell ceph -s &>> /var/log/extra/ceph-status-{% raw %}{{ current_stage }}{% endraw %}.txt
- hosts: ovn_controller
gather_facts: false
become: true
tasks:
- name: get OVN external id parameter at this stage
shell: |
ovs-vsctl get open . external_ids &>> /var/log/extra/ovn_external_id-{% raw %}{{ current_stage }}{% endraw %}.txt
- name: get OVN flows at this stage
shell: |
ovs-ofctl dump-flows br-int &>> /var/log/extra/ovn_flows_id-{% raw %}{{ current_stage }}{% endraw %}.txt
- hosts: pacemaker
gather_facts: false
become: true
tasks:
- name: ensure extra directory is present
file:
name: /var/log/extra
state: directory
owner: root
group: root
mode: 0755
- name: get cluster state at this stage
shell: |
pcs status &>> /var/log/extra/pcslog-{% raw %}{{ current_stage }}{% endraw %}.txt || true
pcs constraint &>> /var/log/extra/pcslog-{% raw %}{{ current_stage }}{% endraw %}.txt || true
- hosts: undercloud
gather_facts: false
become: true
tasks:
- name: ensure extra directory is present
file:
name: /var/log/extra
state: directory
owner: root
group: root
mode: 0755
- name: Information about running vm.
shell: |
for i in $(openstack --os-cloud {{ overcloud_stack_name }} server list -f value -c Name); do
openstack --os-cloud {{ overcloud_stack_name }} server show $i > /var/log/extra/oc-server-$i-{% raw %}{{ current_stage }}{% endraw %}.txt;
done