2015-06-11 23:05:30 +03:00
# Copyright (c) 2015 Ansible, Inc.
2014-08-13 16:48:40 +04:00
# All Rights Reserved.
import sos
2014-08-14 03:22:12 +04:00
from distutils . version import LooseVersion
2014-08-13 16:48:40 +04:00
2015-05-20 22:26:44 +03:00
SOSREPORT_TOWER_COMMANDS = [
" ansible --version " , # ansible core version
" tower-manage --version " , # tower version
" supervisorctl status " , # tower process status
2015-08-25 22:04:19 +03:00
" pip freeze " , # pip package list
2015-05-20 22:26:44 +03:00
" tree -d /var/lib/awx " , # show me the dirs
" ls -ll /var/lib/awx " , # check permissions
" ls -ll /etc/tower " ,
2015-08-25 22:04:19 +03:00
" ls -ll /var/lib/awx/job_status/ "
2015-05-20 22:26:44 +03:00
]
SOSREPORT_TOWER_DIRS = [
" /etc/tower/ " ,
2015-08-25 22:04:19 +03:00
" /etc/ansible/ " ,
2015-05-20 22:26:44 +03:00
" /var/log/tower " ,
" /var/log/httpd " ,
" /var/log/apache2 " ,
" /var/log/redis " ,
" /var/log/supervisor " ,
" /var/log/syslog " ,
" /var/log/udev " ,
" /var/log/kern* " ,
" /var/log/dist-upgrade " ,
" /var/log/installer " ,
" /var/log/unattended-upgrades " ,
" /var/log/apport.log "
]
2015-08-25 22:04:19 +03:00
SOSREPORT_FORBIDDEN_PATHS = [
" /etc/tower/SECRET_KEY " ,
" /etc/tower/tower.key " ,
" /etc/tower/awx.key " ,
" /etc/tower/tower.cert " ,
" /etc/tower/awx.cert "
]
2015-05-20 22:26:44 +03:00
2014-08-14 03:22:12 +04:00
if LooseVersion ( sos . __version__ ) > = LooseVersion ( ' 3.0 ' ) :
2014-08-13 16:48:40 +04:00
from sos . plugins import Plugin , RedHatPlugin , UbuntuPlugin
class tower ( Plugin , RedHatPlugin , UbuntuPlugin ) :
''' Collect Ansible Tower related information '''
plugin_name = " tower "
def setup ( self ) :
2015-05-20 22:26:44 +03:00
for path in SOSREPORT_TOWER_DIRS :
2014-08-13 16:48:40 +04:00
self . add_copy_spec ( path )
2015-08-25 22:04:19 +03:00
for path in SOSREPORT_FORBIDDEN_PATHS :
self . add_forbidden_path ( path )
2015-05-20 22:26:44 +03:00
for command in SOSREPORT_TOWER_COMMANDS :
2014-08-14 21:45:49 +04:00
self . add_cmd_output ( command )
2014-08-13 16:48:40 +04:00
else :
import sos . plugintools
class tower ( sos . plugintools . PluginBase ) :
''' Collect Ansible Tower related information '''
def setup ( self ) :
2015-05-20 22:26:44 +03:00
for path in SOSREPORT_TOWER_DIRS :
2014-08-13 16:48:40 +04:00
self . addCopySpec ( path )
2015-08-25 22:04:19 +03:00
for path in SOSREPORT_FORBIDDEN_PATHS :
self . addForbiddenPath ( path )
2015-05-20 22:26:44 +03:00
for command in SOSREPORT_TOWER_COMMANDS :
2014-08-13 16:48:40 +04:00
self . collectExtOutput ( command )