2bb00e51e4
This new playbook will execute sos-reports and store them within the undercloud. This playbook will replace the support log collection workflow. Story: 2007212 Task: 38431 Task: 38432 Change-Id: I606f1ee3bc323e5c83d09ca9bc8f7e4033e81e70 Signed-off-by: Kevin Carter <kecarter@redhat.com>
144 lines
4.0 KiB
YAML
144 lines
4.0 KiB
YAML
---
|
|
# Copyright 2020 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
- name: Playbook sos-report log collection
|
|
connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}"
|
|
hosts: "{{ tripleo_target_host | default('localhost') }}"
|
|
remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
|
|
gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}"
|
|
any_errors_fatal: true
|
|
vars:
|
|
sos_options:
|
|
- boot
|
|
- cluster
|
|
- hardware
|
|
- kernel
|
|
- memory
|
|
- nfs
|
|
- openstack
|
|
- packagemanager
|
|
- performance
|
|
- services
|
|
- storage
|
|
- system
|
|
- webserver
|
|
- virt
|
|
tasks:
|
|
- name: No server_name defined
|
|
fail:
|
|
msg: >-
|
|
The server_name option was undefined.
|
|
when:
|
|
- server_name is undefined
|
|
|
|
- name: No sos destination defined
|
|
fail:
|
|
msg: >-
|
|
The sos_destination option was undefined.
|
|
when:
|
|
- sos_destination is undefined
|
|
|
|
- name: Create the support directory
|
|
become: true
|
|
file:
|
|
path: "{{ sos_destination }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Set local connection user facts
|
|
set_fact:
|
|
ansible_home: "{{ lookup('env', 'HOME') }}"
|
|
ansible_user: "{{ lookup('env', 'USER') }}"
|
|
run_once: true
|
|
when:
|
|
- (tripleo_target_host is defined) | ternary('ssh', 'local') == 'local'
|
|
|
|
- name: Add ssh-servers
|
|
add_host:
|
|
hostname: "{{ item }}"
|
|
groups: tripleo_queues
|
|
ansible_ssh_private_key_file: "{{ ansible_home }}/.ssh/id_rsa_tripleo"
|
|
sos_destination: "{{ sos_destination }}"
|
|
sos_options: "{{ sos_options | join(',') }}"
|
|
archive_file: "/var/tmp/sos-report-{{ item }}-{{ lookup('pipe','date +%Y%m%d%H%M%S') }}.tgz"
|
|
changed_when: false
|
|
loop: '{{ (server_name == "all") | ternary(
|
|
groups["all"],
|
|
(server_name in groups) | ternary(
|
|
groups[server_name],
|
|
(server_name in groups["all"]) | ternary(
|
|
[server_name],
|
|
(groups["all"] | select("match", server_name ~ ".*") | list)
|
|
)
|
|
)
|
|
)
|
|
}}'
|
|
|
|
|
|
- name: Run Log collection
|
|
hosts: tripleo_queues
|
|
user: tripleo-admin
|
|
gather_facts: false
|
|
strategy: free
|
|
become: true
|
|
handlers:
|
|
- name: Remove tmp directory
|
|
file:
|
|
path: "{{ tempfile_1.path }}"
|
|
state: absent
|
|
|
|
- name: Remove archive
|
|
file:
|
|
path: "{{ archive_file }}"
|
|
state: absent
|
|
tasks:
|
|
- name: Ensure sos is installed
|
|
package:
|
|
name: sos
|
|
|
|
- name: Create temporary directory
|
|
tempfile:
|
|
state: directory
|
|
suffix: build
|
|
register: tempfile_1
|
|
notify:
|
|
- Remove tmp directory
|
|
|
|
- name: Run sos-report
|
|
command: >-
|
|
/usr/sbin/sosreport --batch -p {{ sos_options }} --tmp-dir {{ tempfile_1.path }}
|
|
|
|
- name: Compress sos-report directory
|
|
archive:
|
|
path: "{{ tempfile_1.path }}"
|
|
dest: "{{ archive_file }}"
|
|
|
|
- name: Retrieve the sos report
|
|
fetch:
|
|
src: "{{ archive_file }}"
|
|
dest: "/tmp/"
|
|
flat: true
|
|
|
|
- name: Move archive into place
|
|
command: >-
|
|
mv /tmp/{{ archive_file | basename }} {{ sos_destination }}/
|
|
become: true
|
|
connection: local
|
|
|
|
- name: Archive notice
|
|
debug:
|
|
msg: "Log collection archive: {{ archive_file }}, stored here: {{ sos_destination }}"
|