Skip to main content

A sosreport parser for ansible

Project description

GPL-3.0 licensePyPI versionPR - Pylint StatusPython BuildsPR - Pytest

sos-ansible

This tool has the purpose of achieving easy sosreport reviewing based on custom rules.



Installation and Upgrade

This tool can be installed from pip

$ pip install -U sos_ansible

Sosreport location and rules files

Extract all the sosreport files for evaluation on the same directory as per the example:

$ tar xf sosreport-lbenedit-test-node-xxxx-xxx-xxx.tar.xz -C /tmp/test_sosreport/9999999

As an alternative to using the tar command

sos_ansible -c 999999 -t sosreport-lbenedit-test-node-xxxx-xxx-xxx.tar.xz, sosreport-lbenedit-test-node2-xxxx-xxx-xxx.tar.xz

Note -t or --tarball takes a comma separated list of sosreports and untars them in the /tmp/sosreport by default. Case number is mandatory for untar feature

Use the rules file located in this project or create your own. Sharing your rules with your peers is the key for this tools success.

$ head rules/rules.json                                                                       
{
    "Filesystem": {
        "files": ["df"],
        "path": "",
        "query": "100%"
    },
    "Installed Packages": {
        "files": [
            "installed-rpms"
        ],
        "path": "",
        "query": "ansible, automation, receptor, hub, keycloak"
    }
}

Running the tool and checking the logs

Generate your report by running the sos_ansible main.py code providing the sosreport and rules args.

$ /tmp/git/sos-ansible
$ python sos_ansible
[?] Choose the sos directory: 999999
 > 999999
   01234567

Validating sosreports at the source directory: /tmp/sosreports
Validating rules in place: /tmp/rules.json
Processing node lbenedit-test-node.example.com:
Summary:

lbenedit-test-node.example.com:
--------
Controller Node: True
--------
Filesystem: 1
Installed Packages: 10

Read the matches at /tmp/999999
SOS_ANSIBLE - END

Currently, the tool logs are located on the current directory, file sos-ansible.log.

2023-03-15 15:17:10,839 CRITICAL Validating sosreports at the source directory: /tmp/sosreports
2023-03-15 15:17:10,839 ERROR /tmp/sosreports
2023-03-15 15:17:10,841 CRITICAL Validating rules in place: /tmp/rules.json
2023-03-15 15:17:10,841 DEBUG Node data: [{'hostname': 'lbenedit-test-node.example.com', 'path': '/tmp/sosreports/999999/sosreport-lbenedit-test-node-xxxx-xxx-xxx', 'controller': True}]
2023-03-15 15:17:10,841 DEBUG Current policy: {'Filesystem': {'files': ['df'], 'path': '', 'query': '100%'}, 'Installed Packages': {'files': ['installed-rpms'], 'path': '', 'query': 'ansible, automation, receptor, hub, keycloak'},}
DEBUG Target Directory: /tmp, Case Directory: /tmp/999999
2023-03-15 15:17:10,842 CRITICAL Processing node lbenedit-test-node.example.com:
2023-03-15 15:17:10,864 INFO Populating file /tmp/999999/lbenedit-test-node.example.com/Filesystem
2023-03-15 15:17:10,868 INFO Populating file /tmp/999999/lbenedit-test-node.example.com/Installed_Packages
2023-03-15 15:17:10,870 CRITICAL Summary:

lbenedit-test-node.example.com:
--------
Controller Node: True
--------
Filesystem: 1
Installed Packages: 10

2023-03-15 15:17:10,870 CRITICAL Read the matches at /tmp/999999
2023-03-15 15:17:10,870 CRITICAL SOS_ANSIBLE - END

By default, the tool only offers a summary from all rules processed and you can find the details on the output directory /tmp/{casenumber}

$ cd /tmp/999999/lbenedit-test-node.example.com
$ ls
Filesystem  Installed_Packages
$ cat Filesystem
/dev/mapper/rhel-amazing  12345   12345         0 100% /amazingfs

Running tool via container

An alternative to running this on cli directly is to use the container version:

Running the app with docker-compose

docker-compose run backend bash

Using prebuilt images: Interactive image:

docker pull quay.io/lucas_benedito/sos-ansible-debug

App image:

docker pull quay.io/lucas_benedito/sos-ansible

You may build locally using the following:

from the sos-ansible directory

docker build -t sos-ansible:0.0.1 .

Once the image is built use either podman or docker to run the command:

podman run -it --rm -v /tmp/:/tmp/ -v /full/path/to/rules.json:/tmp/rules.json -v /full/path/to/sos-ansible.log:/home/ansible/sos-ansible.log sos-ansible:0.0.1 -d /tmp/sos_reports/ -r /tmp/rules.json -c 999999 

Breakdown of args:

  • -d directory where sosreports were untarred(should be /tmp/sos_reports if following the earlier instructions)
  • -r path to rules(this can be whatever you specified in the -v option for mounting)
  • -c case/ticket number where you untarred the sosreport to (example from doc is 999999) this argument is mandatory for containerized invocations

Additional notes for troubleshooting containerized tool

Currently if you need to debug what is happening inside the container you can use --entrypoint /bin/bash

example:

podman run --entrypoint /bin/bash -it --rm -v /tmp/:/tmp/ -v /full/path/to/rules.json:/tmp/rules.json -v /full/path/to/sos-ansible.log:/home/ansible/sos-ansible.log sos-ansible:0.0.1

Setup Development Environment

Create virtual environment and use make init.

$ python -m venv venv
$ source venv/bin/activate
$ make init

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sos_ansible-1.0.5.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sos_ansible-1.0.5-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file sos_ansible-1.0.5.tar.gz.

File metadata

  • Download URL: sos_ansible-1.0.5.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for sos_ansible-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f454ca3f40f0b23aab4bdfc50f48f3cd00f49daf66b5f24a68b827846f89b6f2
MD5 e8f73ba58998fdb1bf244302f9e64d3f
BLAKE2b-256 60e5ccdb38e44dbc01cba2bad11d7c16661dce99e3c20c27edc0f25163274d63

See more details on using hashes here.

File details

Details for the file sos_ansible-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: sos_ansible-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for sos_ansible-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9e2bba1b4ee2f4888f573b07b331ac59bf912f98e93ef3bf683c87a293c59e8c
MD5 f95cf32a4fd0ee4927aa601a2c00eecb
BLAKE2b-256 6a2186b58c7d7f74696a5041749a111e0ef3f46ad40056bd0615f528516d3132

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page