forked from ClusterLabs/crmsh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(to make it working, there should be NO --check flag) i.e. $ ./ansible-playbook check.yml -i inventory -e env=dev # --check IMPORTANT: Make sure there is an empty file ansible.txt The blockinfile doesn't create it even if you specify - blockinfile: state: absent Besides, there are * Workaround: crmsh_callback: comment out crmsh.ui_check. This module cannot be found and the whole crmsh_callback won't be loaded. * Remove unnecessary checks
- Loading branch information
Aleksei Burlakov
committed
Jul 24, 2024
1 parent
4b38e34
commit aeb9d34
Showing
77 changed files
with
1,386 additions
and
1,115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/python3.11 | ||
# EASY-INSTALL-ENTRY-SCRIPT: 'ansible-core==2.16.8','console_scripts','ansible-playbook' | ||
import re | ||
import sys | ||
|
||
# for compatibility with easy_install; see #2198 | ||
__requires__ = 'ansible-core==2.16.8' | ||
|
||
try: | ||
from importlib.metadata import distribution | ||
except ImportError: | ||
try: | ||
from importlib_metadata import distribution | ||
except ImportError: | ||
from pkg_resources import load_entry_point | ||
|
||
|
||
def importlib_load_entry_point(spec, group, name): | ||
dist_name, _, _ = spec.partition('==') | ||
matches = ( | ||
entry_point | ||
for entry_point in distribution(dist_name).entry_points | ||
if entry_point.group == group and entry_point.name == name | ||
) | ||
return next(matches).load() | ||
|
||
|
||
globals().setdefault('load_entry_point', importlib_load_entry_point) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) | ||
sys.exit(load_entry_point('ansible-core==2.16.8', 'console_scripts', 'ansible-playbook')()) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/usr/bin/python3 | ||
from __future__ import unicode_literals | ||
from builtins import str | ||
import os | ||
import pwd | ||
import hashlib | ||
import platform | ||
import callback_plugins.scripts.crm_script as crm_script | ||
|
||
import crmsh.log | ||
crmsh.log.setup_logging() | ||
from crmsh.report import utils | ||
|
||
try: | ||
import json | ||
except ImportError: | ||
import simplejson as json | ||
|
||
data = crm_script.get_input() | ||
|
||
PACKAGES = ['booth', 'cluster-glue', 'corosync', 'crmsh', 'csync2', 'drbd', | ||
'fence-agents', 'gfs2', 'gfs2-utils', 'ha-cluster-bootstrap', | ||
'haproxy', 'hawk', 'libdlm', 'libqb', 'ocfs2', 'ocfs2-tools', | ||
'pacemaker', 'pacemaker-mgmt', 'resource-agents', 'sbd'] | ||
|
||
|
||
def rpm_info(): | ||
return crm_script.rpmcheck(PACKAGES) | ||
|
||
|
||
def logrotate_info(): | ||
return {} | ||
|
||
|
||
def get_user(): | ||
return pwd.getpwuid(os.getuid()).pw_name | ||
|
||
|
||
def sys_info(): | ||
sysname, nodename, release, version, machine = os.uname() | ||
# The first three columns measure CPU and IO utilization of the | ||
# last one, five, and 15 minute periods. The fourth column shows | ||
# the number of currently running processes and the total number of | ||
# processes. The last column displays the last process ID used. | ||
system, node, release, version, machine, processor = platform.uname() | ||
distname = utils.get_distro_info() | ||
hostname = os.uname()[1] | ||
|
||
uptime = open('/proc/uptime').read().split() | ||
loadavg = open('/proc/loadavg').read().split() | ||
|
||
return {'system': system, | ||
'node': node, | ||
'release': release, | ||
'version': version, | ||
'machine': machine, | ||
'processor': processor, | ||
'distname': distname, | ||
'user': get_user(), | ||
'hostname': hostname, | ||
'uptime': uptime[0], | ||
'idletime': uptime[1], | ||
'loadavg': loadavg[2] # 15 minute average | ||
} | ||
|
||
|
||
def disk_info(): | ||
rc, out, err = crm_script.call(['df'], shell=False) | ||
if rc == 0: | ||
disk_use = [] | ||
for line in out.split('\n')[1:]: | ||
line = line.strip() | ||
if line: | ||
data = line.split() | ||
if len(data) >= 6: | ||
disk_use.append((data[5], data[4])) | ||
return disk_use | ||
return [] | ||
|
||
|
||
# configurations out of sync | ||
|
||
FILES = [ | ||
'/etc/csync2/key_hagroup', | ||
'/etc/csync2/csync2.cfg', | ||
'/etc/corosync/corosync.conf', | ||
'/etc/sysconfig/sbd' | ||
] | ||
|
||
|
||
def files_info(): | ||
ret = {} | ||
for f in FILES: | ||
if os.path.isfile(f): | ||
try: | ||
ret[f] = hashlib.sha1(open(f).read().encode('utf-8')).hexdigest() | ||
except IOError as e: | ||
ret[f] = "error: %s" % (e) | ||
else: | ||
ret[f] = "" | ||
return ret | ||
|
||
def do_collect(): | ||
try: | ||
data = { | ||
'rpm': rpm_info(), | ||
'logrotate': logrotate_info(), | ||
'system': sys_info(), | ||
'disk': disk_info(), | ||
'files': files_info() | ||
} | ||
#crm_script.exit_ok(data) | ||
print(json.dumps(data)) | ||
except Exception as e: | ||
crm_script.exit_fail(str(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/python3 | ||
import os | ||
import sys | ||
import shutil | ||
errors = [] | ||
mydir = os.path.dirname(os.path.abspath(sys.modules[__name__].__file__)) | ||
|
||
|
||
def bad(path): | ||
return ((not os.path.isabs(path)) or os.path.dirname(path) == '/' or | ||
path.startswith('/var') or path.startswith('/usr') or | ||
(not path.startswith(mydir))) | ||
|
||
for f in sys.argv[1:]: | ||
if bad(f): | ||
errors.append("cannot remove %s from %s" % (f, mydir)) | ||
continue | ||
try: | ||
if os.path.isfile(f): | ||
os.remove(f) | ||
elif os.path.isdir(f): | ||
if os.path.isfile(os.path.join(f, 'crm_script.debug')): | ||
print(open(os.path.join(f, 'crm_script.debug')).read()) | ||
|
||
# to check whether this clean request came from health | ||
# if it does, delete all except health-report | ||
del_flag = 0 | ||
for x in os.listdir(f): | ||
if x.startswith("health-report"): | ||
del_flag = 1 | ||
|
||
if del_flag == 1: | ||
for x in os.listdir(f): | ||
if x.startswith("health-report"): | ||
continue | ||
if os.path.isfile(x): | ||
os.remove(x) | ||
elif os.path.isdir(x): | ||
shutil.rmtree(x) | ||
else: | ||
shutil.rmtree(f) | ||
except OSError as e: | ||
errors.append(e) | ||
if errors: | ||
print('\n'.join(errors), file=sys.stderr) | ||
sys.exit(1) |
Oops, something went wrong.