pythonzm / Ops

基于centos6+python3.6+django2+ansible2.4+celery4.2 运维管理系统,目前实现功能:用户和用户组管理、资产管理、集成ansible2.4、简易堡垒机(主机分配支持rdp以及vnc、用户分配、文件上传下载、配置禁用命令清单、操作录像回放功能)、CI/CD(支持git仓库和svn仓库)、数据库管理(一部分)、celery任务编排、知识库及文件共享
713 stars 320 forks source link

求教playbook和run_module的日志写入放在了哪里? #6

Closed NikelChamp closed 5 years ago

NikelChamp commented 5 years ago

新年好,大神,我看到middleware.py里面的run_module和playbook的日志写入部分删除了,请问现在是怎么处理的呢?

pythonzm commented 5 years ago

我修改了实现方式,现在ansible这块儿执行结果都是通过websocket实时显示并且通过celery异步存储,存储函数我分别放在了task/utils/ans_module_websocket.py 和 task/utils/ans_playbook_websocket.py 中了

NikelChamp commented 5 years ago

我修改了实现方式,现在ansible这块儿执行结果都是通过websocket实时显示并且通过celery异步存储,存储函数我分别放在了task/utils/ans_module_websocket.py 和 task/utils/ans_playbook_websocket.py 中了

我这里playbook的日志好像没有写入,module_log没问题

[2019-02-14 08:50:14,583: INFO/MainProcess] Received task: task.tasks.playbook_record[9f572f2f-2f2b-4dbe-8709-7674ec3f47f7]  
[2019-02-14 09:06:02,881: INFO/MainProcess] Received task: task.tasks.playbook_record[725f5fc1-1aa0-41e6-80bd-ca1801014365]

worker日志也显示有执行过,但是表里没发现记录

pythonzm commented 5 years ago

你看任务管理模块里中的结果,里面有没有记录错误

NikelChamp commented 5 years ago

日志有了,还有一个问题,执行role的时候websocket连上秒断,没有显示执行过程,也没有执行过role, 但是执行单一playbook没问题

[2019/02/15  17:03:32] WebSocket HANDSHAKING /ws/ans_playbook_log/ [127.0.0.1:57534]
[2019/02/15  17:03:32] WebSocket CONNECT /ws/ans_playbook_log/ [127.0.0.1:57534]
[2019/02/15  17:03:32] WebSocket DISCONNECT /ws/ans_playbook_log/ [127.0.0.1:57534]

控制台显示是秒断的,然后日志表里面playbook_result是个空列表

pythonzm commented 5 years ago

在web界面F12看一下console,是不是websocket报错了

NikelChamp commented 5 years ago

关于fort 禁用命令的部分我不是太明白,尝试禁用/bin/rm, 但还是可以删除

pythonzm commented 5 years ago

禁用命令就是将命令加入到该用户的sudo文件中,给某个用户禁用了rm命令,是指该用户可以用rm命令删除所属用户是该用户的文件,但是不能使用rm删除其他用户的文件

NikelChamp commented 5 years ago

明白了,再请教一下主机组变量和主机变量不是一个配置吧?字典格式是{key1: vaule1, key2: vaule2 }这样传入吗?

pythonzm commented 5 years ago

主机变量是为某个主机单独配置的变量,主机组变量是给指定组内所有主机配置的变量,字典格式没问题

NikelChamp commented 5 years ago

现在是能多组执行了对么?对了webshell好像不能输入数字

pythonzm commented 5 years ago

可以多组执行了,webssh输入数字是有点儿问题,之前代码里的判断太笼统了,忘了改了。。

NikelChamp commented 5 years ago

我配了uwsgi.ini,但是执行uwsgi --ini ops-uwsgi.ini的时候,控制台只返回这个

[uWSGI] getting INI configuration from ops-uwsgi.ini

然后就结束了,好像根本没起来

pythonzm commented 5 years ago

uwsgi咋配置的?

NikelChamp commented 5 years ago

uwsgi咋配置的?

[uwsgi]
socket = /var/run/Ops.sock
chdir = /testops/Ops
wsgi-file = /testops/Ops/wsgi.py
processes = 2
enable-threads = true
threads = 2
stats = 127.0.0.1:9000
daemonize = /var/log/Ops.log
pidfile = /var/log/Ops.pid
http-timeout = 6000
py-autoreload = 1
vacuum = true

有问题吗

pythonzm commented 5 years ago

wsgi-file 配置错了,改成 wsgi-file = Ops/wsgi.py

NikelChamp commented 5 years ago

wsgi-file 配置错了,改成 wsgi-file = Ops/wsgi.py

还是不行,直接加载配置之后就停了

[uWSGI] getting INI configuration from ops-uwsgi.ini
pythonzm commented 5 years ago

看看/var/log/Ops.log有啥输出

NikelChamp commented 5 years ago
*** Starting uWSGI 2.0.17.1 (64bit) on [Thu Feb 28 14:26:17 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-36) on 21 December 2018 03:46:48
os: Linux-3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
nodename: test123
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /testops/Ops
writing pidfile to /var/log/Ops.pid
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
chdir() to /testops/Ops/
your processes number limit is 7168
your memory page size is 4096 bytes
detected max file descriptor number: 4096
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/run/Ops.sock fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.6.2 (default, Nov  2 2018, 16:55:10)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Python main interpreter initialized at 0x1373000
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 250128 bytes (244 KB) for 4 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x1373000 pid: 101184 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 101184)
spawned uWSGI worker 1 (pid: 101189, cores: 2)
spawned uWSGI worker 2 (pid: 101190, cores: 2)
*** Stats server enabled on 0.0.0.0:9191 fd: 20 ***
Python auto-reloader enabled

log显示pid是有的

NikelChamp commented 5 years ago

assets_terminal好像上传不了了,一直报红Are you sure to continue? 控制显示404

[2019/03/01 11:14:57] HTTP POST /assets/ssh/2%20/ 404 [0.03, 192.168.15.179:59769]
pythonzm commented 5 years ago

log日志输出正常啊,说明uwsgi启动没问题。上传这块儿确实有问题,我正在写CI/CD功能,等写得差不多了再一块儿更新吧