Giter Club home page Giter Club logo

ansible-api's Introduction

ansible-api v0.5.1

A restful http api for ansible python version >= 3.7

What is it?

Ansible is a radically simple IT automation system. If you are trying to use it and not like CLI, you can try me now. I can provide you use ansible by A RESTful HTTP Api and a realtime processing message (websocket api), you can see all details.

Changelog

  • 0.5.1
    • add sha256 encryption support for signature (thx: jbackman)
    • fit for latest ansible(v2.8.6) and ansible-runner(v1.4.2)
    • add more error event capture in response
  • 0.5.0 replace tornado with sanic, more lightly (python>=3.7)
  • 0.3.0 using ansible-runner as middleware
  • 0.2.6 adaptive ansible 2.6.4 and add asynchronization mode
  • 0.2.2 optimize log
  • 0.2.1 optimize log and allow mutil-instance in the same host
  • 0.2.0 support websocket, remove code invaded in ansible

Structure chart

image

How to install

  • [preparatory work] python version >= 3.7 (use asyncio featrue)
  • pip3 install ansible-api

How to start it

  • default configuration: /etc/ansible/api.cfg
  • start:
ansible-api -c [Configfile, Optional] -d [Daemon Mode, Optional]

eg: ansible-api -c /etc/ansible/api.cfg -d > /dev/null &

How to prepare your data

HTTP API Usage

ansible-api's People

Contributors

lfbear avatar w6zhou avatar zhaoyu1123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-api's Issues

启动报这个错误

ansible-api -c /etc/ansible/api.cfg -d
Traceback (most recent call last):
File "/usr/bin/ansible-api", line 18, in
from ansible_api.webapi import WebApi
File "/usr/lib/python2.7/site-packages/ansible_api/webapi.py", line 16, in
from ansible_api import controller
File "/usr/lib/python2.7/site-packages/ansible_api/controller.py", line 36, in
executor = futures.ThreadPoolExecutor(int(Config.Get('thread_pool_size')))
ValueError: invalid literal for int() with base 10: ''
[root@bogon ansible-api]#

Error: Failed when parsing body as json

uri= /command
data={"n":"test1","m":"command","t":"127.0.0.1","a":"uptime","s":"42e075802d3bfae76cc0f78dfbe34669"}
sign_key = "ansible-api-key"

image
why i get
Error: Failed when parsing body as json

ERROR argument of type NoneType is not iterable

2019-10-10 06:14:40 | ERROR - argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "/usr/local/python37/lib/python3.7/site-packages/ansible_api/controller.py", line 106, in post
response = await loop.run_in_executor(pool, self.run, target, name, module, arg, cb)
File "/usr/local/python37/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/python37/lib/python3.7/site-packages/ansible_api/controller.py", line 119, in run
event_handler=cb.event_handler, status_handler=cb.status_handler
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/interface.py", line 162, in run
r.run()
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/runner.py", line 177, in run
searchwindowsize=100)
File "/usr/local/python37/lib/python3.7/site-packages/pexpect/spawnbase.py", line 341, in expect
timeout, searchwindowsize, async_)
File "/usr/local/python37/lib/python3.7/site-packages/pexpect/spawnbase.py", line 369, in expect_list
return exp.expect_loop(timeout)
File "/usr/local/python37/lib/python3.7/site-packages/pexpect/expect.py", line 111, in expect_loop
incoming = spawn.read_nonblocking(spawn.maxread, timeout)
File "/usr/local/python37/lib/python3.7/site-packages/pexpect/pty_spawn.py", line 500, in read_nonblocking
return super(spawn, self).read_nonblocking(size)
File "/usr/local/python37/lib/python3.7/site-packages/pexpect/spawnbase.py", line 179, in read_nonblocking
self._log(s, 'read')
File "/usr/local/python37/lib/python3.7/site-packages/pexpect/spawnbase.py", line 130, in _log
second_log.write(s)
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/utils.py", line 251, in write
event_data = self._emit_event(value[:match.start()], event_data)
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/utils.py", line 326, in _emit_event
self._event_callback(event_data)
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/runner.py", line 68, in event_callback
should_write = self.event_handler(event_data)
File "/usr/local/python37/lib/python3.7/site-packages/ansible_api/callback.py", line 31, in event_handler
detail = rpt.detail()
File "/usr/local/python37/lib/python3.7/site-packages/ansible_api/report.py", line 88, in detail
if o in detail['res']:
TypeError: argument of type 'NoneType' is not iterable
[2019-10-10 06:14:40 +0000] - (sanic.access)[INFO][192.168.56.1:55071]: POST http://192.168.56.102:8765/command 200 62
2019-10-10 06:14:40 | INFO -
[2019-10-10 06:14:45 +0000] [522] [DEBUG] KeepAlive Timeout. Closing connection.
2019-10-10 06:14:45 | DEBUG - KeepAlive Timeout. Closing connection

ERROR status_handler() got an unexpected keyword argument runner_config

2019-10-10 07:04:32 | ERROR - status_handler() got an unexpected keyword argument 'runner_config'
Traceback (most recent call last):
File "/usr/local/python37/lib/python3.7/site-packages/ansible_api/controller.py", line 106, in post
response = await loop.run_in_executor(pool, self.run, target, name, module, arg, cb)
File "/usr/local/python37/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/python37/lib/python3.7/site-packages/ansible_api/controller.py", line 119, in run
event_handler=cb.event_handler, status_handler=cb.status_handler
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/interface.py", line 162, in run
r.run()
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/runner.py", line 93, in run
self.status_callback('starting')
File "/usr/local/python37/lib/python3.7/site-packages/ansible_runner/runner.py", line 86, in status_callback
self.status_handler(status_data, runner_config=self.config)
TypeError: status_handler() got an unexpected keyword argument 'runner_config'

这个是要配置什么?

58行时间是否用本地时间更好?

ansible-api文件
report = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime()) + ' | ' + str
改为
report = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + ' | ' + str
58行时间是否用本地时间更好?

不知道哪里出错了

{"rc": 0, "detail": {}}
把callback里面的 crucial 类型打印出来是 <class 'ansible.playbook.play.Play'>

启动报这个错误

[root@centos6a v2.2.0]# ansible-api
Traceback (most recent call last):
File "/usr/bin/ansible-api", line 32, in
from ansible.executor.process.detail import DetailProcess
ImportError: No module named detail
[root@centos6a v2.2.0]#

有个问题咨询下IP多的情况下慢

有个问题咨询下IP多的情况下慢,当用API接口,执行的IP大概50几个,就挺慢的
2016-07-13 18:03:40,545 root 200 POST /command (192.168.10.100) 71112.74ms
2016-07-13 18:04:26,531 root 200 POST /command (192.168.10.100) 45984.78ms
2016-07-13 18:15:24,056 root 200 POST /command (192.168.10.100) 1353.50ms
2016-07-13 18:15:25,294 root 200 POST /command (192.168.10.100) 1224.92ms
2016-07-13 19:03:09,533 root 200 POST /command (192.168.10.100) 2773.29ms
2016-07-13 19:03:11,669 root 200 POST /command (192.168.10.100) 2124.39ms
2016-07-13 20:06:22,691 root 200 POST /command (192.168.10.100) 37304.66ms
2016-07-13 20:06:50,128 root 200 POST /command (192.168.10.100) 27434.13ms
2016-07-13 20:12:11,569 root 200 POST /command (192.168.10.100) 37380.19ms
2016-07-13 20:12:53,877 root 200 POST /command (192.168.10.100) 42305.30ms
2016-07-13 20:47:52,275 root 200 POST /command (192.168.10.100) 52342.11ms
2016-07-13 20:48:29,778 root 200 POST /command (192.168.10.100) 37499.82ms
这个是慢在等返回结果吗?有办法优化吗?
是顺序执行每个IP还是并行执行的?ansible不是并行的么?

不能在B网段启动吗?

ansible.cfg

==============================================

Config file for Ansible-Api

A restful http api for ansible 2.x

I am not a part of ansible official code

==============================================

Base configuration part

[default]

#listen host
host = 10.0.200.115
#listen port
port = 8765
#signature string for api call
sign_key = YOUR_SIGNATURE_KEY_HERE
#log path if using daemon mode
log_path = /var/log/ansible-api.log
#ip white list (multiple separated by space, leave a blank for all allowed)
allow_ip =
#concurrence task number (default:4)
thread_pool_size =

Optional configuration part

if you wanna use the feature of file managing

[directory]
#your playbook path (file *.yml in this dir will be worked)
playbook = ~
#your script path (file *.sh in this dir will be worked)
script = ~
#your authkeys path (file */authorized_keys in this dir will be worked)
authkeys =

其中10.0.200.115的掩码是255.255.0.0

这个ip从外部使用ssh进入没有问题。

启动时出错信息:
Ansible API is running in Debug Mode
Traceback (most recent call last):
File "/usr/bin/ansible-api", line 32, in
app = WebApi()
File "/usr/lib/python2.7/site-packages/ansible_api/webapi.py", line 35, in init
http_server.listen(Config.Get('port'), Config.Get('host'))
File "/usr/lib64/python2.7/site-packages/tornado/tcpserver.py", line 126, in listen
sockets = bind_sockets(port, address=address)
File "/usr/lib64/python2.7/site-packages/tornado/netutil.py", line 194, in bind_sockets
sock.bind(sockaddr)
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address

WARNING - Unknown event name: verbose

2019-10-23 15:04:19 | INFO - run: test1, 172.18.8.2, command, df -Th
2019-10-23 15:04:19 | DEBUG - [#DEAULT#@websocket] {'task_name': 'test1', 'task_id': '#', 'type': 5, 'ctime': '2019-10-23 15:04:19', 'host_list': ['172.18.8.2'], 'task_list': ['command'], 'msg': {'kind': 'play_start', 'value': 'command'}}
2019-10-23 15:04:20 | WARNING - Unknown event name: verbose
2019-10-23 15:04:20 | WARNING - Unknown event name: verbose

return:
{'rc': 250, 'detail': {}}

unsupported parameter for module: --exclude

POST:
{"m":"command","a":"/usr/bin/rsync -av --delete /tmp/ansible/aaa /tmp/ansible/bbb --exclude=log","t":"192.168.10.12","s":"xxxxxxxxxxxx0be25513e","r":"false"}

不支持这个 --exclude=log?
有办法能支持下吗?

No file descriptors available

使用接口调用时,当执行大量的主机链接,会出现文件打开数过多,或者程序僵死

  • No file descriptors available

2018-12-17 08:44:04 | ERROR - A serious error occurs
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/ansible_api/controller.py", line 195, in post
SyncPool, Api.run_play_book, name, yml_file, hosts, forks, host_info, my_vars)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/ansible_api/core.py", line 139, in run_play_book
rc = pbex.run()
File "/usr/lib/python3.6/site-packages/ansible/executor/playbook_executor.py", line 156, in run
result = self._tqm.run(play=play)
File "/usr/lib/python3.6/site-packages/ansible/executor/task_queue_manager.py", line 268, in run
self._initialize_processes(min(self._options.forks, iterator.batch_size))
File "/usr/lib/python3.6/site-packages/ansible/executor/task_queue_manager.py", line 117, in _initialize_processes
rslt_q = multiprocessing.Queue()
File "/usr/lib/python3.6/multiprocessing/context.py", line 102, in Queue
return Queue(maxsize, ctx=self.get_context())
File "/usr/lib/python3.6/multiprocessing/queues.py", line 47, in init
self._wlock = ctx.Lock()
File "/usr/lib/python3.6/multiprocessing/context.py", line 67, in Lock
return Lock(ctx=self.get_context())
File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 163, in init
SemLock.init(self, SEMAPHORE, 1, 1, ctx=ctx)
File "/usr/lib/python3.6/multiprocessing/synchronize.py", line 60, in init
unlink_now)
OSError: [Errno 24] No file descriptors available

  • A worker was found in a dead state

2018-12-17 08:46:04 | WARNING - Found a new type in result [<class 'ansible.playbook.Playbook'>]
2018-12-17 08:46:07 | ERROR - A serious error occurs
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/ansible_api/controller.py", line 195, in post
SyncPool, Api.run_play_book, name, yml_file, hosts, forks, host_info, my_vars)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/ansible_api/core.py", line 139, in run_play_book
rc = pbex.run()
File "/usr/lib/python3.6/site-packages/ansible/executor/playbook_executor.py", line 156, in run
result = self._tqm.run(play=play)
File "/usr/lib/python3.6/site-packages/ansible/executor/task_queue_manager.py", line 292, in run
play_return = strategy.run(iterator, play_context)
File "/usr/lib/python3.6/site-packages/ansible/plugins/strategy/linear.py", line 323, in run
results += self._wait_on_pending_results(iterator)
File "/usr/lib/python3.6/site-packages/ansible/plugins/strategy/init.py", line 672, in _wait_on_pending_results
raise AnsibleError("A worker was found in a dead state")
ansible.errors.AnsibleError: A worker was found in a dead state

查看进程打开文件,其中有很多类似下面的打开,似乎是进程间的通讯

ansible-a 21524 root DEL REG 0,41 13571641 /dev/shm/sem.QqlmoW
ansible-a 21524 root DEL REG 0,41 13571640 /dev/shm/sem.xlGJ5w
ansible-a 21524 root DEL REG 0,41 13571639 /dev/shm/sem.gN57M7
ansible-a 21524 root DEL REG 0,41 13571637 /dev/shm/sem.wMBxuI
ansible-a 21524 root DEL REG 0,41 13571636 /dev/shm/sem.tRKYbj
ansible-a 21524 root DEL REG 0,41 13571635 /dev/shm/sem.71RqTT
ansible-a 21524 root DEL REG 0,41 13571633 /dev/shm/sem.SY9TAu
ansible-a 21524 root DEL REG 0,41 13571632 /dev/shm/sem.wJepi5
ansible-a 21524 root DEL REG 0,41 13571631 /dev/shm/sem.W0wVZF
ansible-a 21524 root DEL REG 0,41 13571629 /dev/shm/sem.0pwtHg
ansible-a 21524 root DEL REG 0,41 13571628 /dev/shm/sem.pzt3oR
ansible-a 21524 root DEL REG 0,41 13571627 /dev/shm/sem.FaAE6r
ansible-a 21524 root DEL REG 0,41 13571625 /dev/shm/sem.AMKgO2
ansible-a 21524 root DEL REG 0,41 13571624 /dev/shm/sem.RsRUvD
ansible-a 21524 root DEL REG 0,41 13571623 /dev/shm/sem.alaAde
ansible-a 21524 root DEL REG 0,41 13583389 /dev/shm/sem.ATMiVO
ansible-a 21524 root DEL REG 0,41 13583386 /dev/shm/sem.vJp3Ip
ansible-a 21524 root DEL REG 0,41 13583385 /dev/shm/sem.z6Ugp2
ansible-a 21524 root DEL REG 0,41 13583384 /dev/shm/sem.Zdxv5E
ansible-a 21524 root DEL REG 0,41 13579310 /dev/shm/sem.CwHMLh
ansible-a 21524 root DEL REG 0,41 13579309 /dev/shm/sem.syhNYV
ansible-a 21524 root DEL REG 0,41 13579308 /dev/shm/sem.D72RbA
ansible-a 21524 root DEL REG 0,41 13579307 /dev/shm/sem.qWy5oe
ansible-a 21524 root DEL REG 0,41 13579306 /dev/shm/sem.b55jCS
ansible-a 21524 root DEL REG 0,41 13579305 /dev/shm/sem.454zPw
ansible-a 21524 root DEL REG 0,41 13579304 /dev/shm/sem.WAMR2a
ansible-a 21524 root DEL REG 0,41 13579303 /dev/shm/sem.tqcbgP
ansible-a 21524 root DEL REG 0,41 13579302 /dev/shm/sem.vemxtt
ansible-a 21524 root DEL REG 0,41 13579301 /dev/shm/sem.8ZTUG7
ansible-a 21524 root DEL REG 0,41 13579300 /dev/shm/sem.PeyjUL
ansible-a 21524 root DEL REG 0,41 13579299 /dev/shm/sem.jxbJ7p
ansible-a 21524 root DEL REG 0,41 13579298 /dev/shm/sem.S0J9k4
ansible-a 21524 root DEL REG 0,41 13579297 /dev/shm/sem.UvfByI
ansible-a 21524 root DEL REG 0,41 13579296 /dev/shm/sem.ZOF3Lm
ansible-a 21524 root DEL REG 0,41 13579295 /dev/shm/sem.Pg2wZ0
ansible-a 21524 root DEL REG 0,41 13579294 /dev/shm/sem.2Vm1cF
ansible-a 21524 root DEL REG 0,41 13579293 /dev/shm/sem.GDGwqj
ansible-a 21524 root DEL REG 0,41 13579292 /dev/shm/sem.sBc3DX
ansible-a 21524 root DEL REG 0,41 13579291 /dev/shm/sem.ROJARB
ansible-a 21524 root DEL REG 0,41 13579290 /dev/shm/sem.Bed94f
ansible-a 21524 root 9u sock 0,7 0t0 13577253 protocol: UNIX
ansible-a 21524 root 13u REG 253,0 0 67992384 /tmp/#67992384 (deleted)
ansible-a 21524 root 14u sock 0,7 0t0 13583390 protocol: TCP
ansible-a 21524 root 16w FIFO 0,9 0t0 13571622 pipe
ansible-a 21524 root 18w FIFO 0,9 0t0 13571626 pipe
ansible-a 21524 root 20w FIFO 0,9 0t0 13571630 pipe
ansible-a 21524 root 22w FIFO 0,9 0t0 13571634 pipe
ansible-a 21524 root 24w FIFO 0,9 0t0 13571638 pipe
ansible-a 21524 root 26w FIFO 0,9 0t0 13571642 pipe
ansible-a 21524 root 28w FIFO 0,9 0t0 13571646 pipe
ansible-a 21524 root 30w FIFO 0,9 0t0 13571650 pipe
ansible-a 21524 root 32w FIFO 0,9 0t0 13571654 pipe
ansible-a 21524 root 34w FIFO 0,9 0t0 13571658 pipe
ansible-a 21524 root 36w FIFO 0,9 0t0 13571662 pipe
ansible-a 21524 root 38w FIFO 0,9 0t0 13571666 pipe
ansible-a 21524 root 40w FIFO 0,9 0t0 13571670 pipe
ansible-a 21524 root 42w FIFO 0,9 0t0 13571674 pipe
ansible-a 21524 root 44w FIFO 0,9 0t0 13571678 pipe
ansible-a 21524 root 46w FIFO 0,9 0t0 13571682 pipe
ansible-a 21524 root 48w FIFO 0,9 0t0 13571686 pipe
ansible-a 21524 root 50w FIFO 0,9 0t0 13571690 pipe
ansible-a 21524 root 52w FIFO 0,9 0t0 13571694 pipe
ansible-a 21524 root 54w FIFO 0,9 0t0 13571698 pipe
ansible-a 21524 root 56w FIFO 0,9 0t0 13571702 pipe
ansible-a 21524 root 58w FIFO 0,9 0t0 13571706 pipe
ansible-a 21524 root 60w FIFO 0,9 0t0 13571710 pipe
ansible-a 21524 root 62w FIFO 0,9 0t0 13571714 pipe
ansible-a 21524 root 64w FIFO 0,9 0t0 13571718 pipe
ansible-a 21524 root 66w FIFO 0,9 0t0 13571722 pipe
ansible-a 21524 root 68w FIFO 0,9 0t0 13571726 pipe
ansible-a 21524 root 70w FIFO 0,9 0t0 13571730 pipe
ansible-a 21524 root 72w FIFO 0,9 0t0 13571734 pipe
ansible-a 21524 root 74w FIFO 0,9 0t0 13571738 pipe
ansible-a 21524 root 75r FIFO 0,9 0t0 13628594 pipe
ansible-a 21524 root 76r FIFO 0,9 0t0 13628595 pipe
ansible-a 21524 root 83r FIFO 0,9 0t0 13625587 pipe
ansible-a 21524 root 84r FIFO 0,9 0t0 13625588 pipe
ansible-a 21524 root 85u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 86r FIFO 0,9 0t0 13625589 pipe
ansible-a 21524 root 87u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 88r FIFO 0,9 0t0 13625590 pipe
ansible-a 21524 root 89u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 90r FIFO 0,9 0t0 13625591 pipe
ansible-a 21524 root 91u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 92r FIFO 0,9 0t0 13625592 pipe
ansible-a 21524 root 93u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 94r FIFO 0,9 0t0 13628554 pipe
ansible-a 21524 root 95u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 96r FIFO 0,9 0t0 13628555 pipe
ansible-a 21524 root 97u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 98r FIFO 0,9 0t0 13628556 pipe
ansible-a 21524 root 99u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 100r FIFO 0,9 0t0 13628557 pipe
ansible-a 21524 root 101u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 102r FIFO 0,9 0t0 13628561 pipe
ansible-a 21524 root 103u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 104r FIFO 0,9 0t0 13628562 pipe
ansible-a 21524 root 105u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 106r FIFO 0,9 0t0 13627624 pipe
ansible-a 21524 root 107u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 108r FIFO 0,9 0t0 13627625 pipe
ansible-a 21524 root 109u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 110r FIFO 0,9 0t0 13628563 pipe
ansible-a 21524 root 111u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 112r FIFO 0,9 0t0 13628564 pipe
ansible-a 21524 root 113u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 114r FIFO 0,9 0t0 13628565 pipe
ansible-a 21524 root 115u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 116r FIFO 0,9 0t0 13628566 pipe
ansible-a 21524 root 117u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 118r FIFO 0,9 0t0 13628567 pipe
ansible-a 21524 root 119u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 120r FIFO 0,9 0t0 13629481 pipe
ansible-a 21524 root 121u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 122r FIFO 0,9 0t0 13628592 pipe
ansible-a 21524 root 123u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 124r FIFO 0,9 0t0 13628593 pipe
ansible-a 21524 root 125u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 126u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 127u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 128u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 129u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 130u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 132u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 133u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 134u CHR 136,0 0t0 3 /dev/pts/0
ansible-a 21524 root 135u CHR 136,0 0t0 3

POST没执行

POST:
{"m":"command","a":"df -h","t":"192.168.142.136","s":"f48576acacdd56fb0d96c6355dfd7d44","r":"False"}

显示这个是什么,也没执行df -f命令
{"detail": {}, "rc": 0}

换另外台
POST:
{"m":"command","a":"df -h","t":"192.168.142.137","s":"c30934a5ad5b6e01991c6bc33c505241","r":"False"}
显示这个
{"detail": {"192.168.142.137": [{"msg": "Failed to connect to the host via ssh.", "unreachable": true, "changed": false, "task_name": "command"}]}, "rc": 3}

调用接口,提示连接不上远程主机

我已经把服务端的ssh公匙复制到远程机器上面,SSH信任测试没问题,但是调用的时候却提示连接不上。以下是是详情。
返回信息:

{
"rc": 4,
"detail": {
"172.20.66.20": [
{
"host": "172.20.66.20",
"task_name": "command",
"rc": 1,
"unreachable": true,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n"
}
]
}
}

日志:

2018-12-13 17:19:25 | INFO - run: 123123, 172.20.66.20, command, df -h, True, 50
2018-12-13 17:19:26 | INFO - TASK DETAIL: #DEAULT# 123123 # play_start 123123
2018-12-13 17:19:26 | DEBUG - [#DEAULT#@websocket] {'rc': 0, 'task_name': '123123', 'task_list': ['command'], 'host_list': ['172.20.66.20'], 'msg': {'kind': 'play_start', 'value': '123123'}, 'task_id': '#', 'type': 5, 'ctime': '2018-12-13 17:19:26'}
2018-12-13 17:19:26 | INFO - TASK DETAIL: #DEAULT# 123123 # task_start command
2018-12-13 17:19:26 | DEBUG - [#DEAULT#@websocket] {'rc': 0, 'task_name': '123123', 'msg': {'kind': 'task_start', 'value': 'command'}, 'task_id': '#', 'type': 5, 'ctime': '2018-12-13 17:19:26'}
2018-12-13 17:19:26 | WARNING - ERROR DETAIL: #DEAULT# {'msg': {'host': '172.20.66.20', 'task_name': 'command', 'rc': 1, 'unreachable': True, 'msg': 'Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n'}, 'rc': 1, 'task_name': '123123', 'task_id': '#', 'type': 6, 'ctime': '2018-12-13 17:19:26'}

runner_config problem

"error": "status_handler() got an unexpected keyword argument 'runner_config'",

this is the stack:

2019-03-24 18:17:56 | ERROR - status_handler() got an unexpected keyword argument 'runner_config'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/ansible_api/controller.py", line 162, in post
    response = await loop.run_in_executor(pool, self.run, hosts, name, yml_file, my_vars, cb)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/dist-packages/ansible_api/controller.py", line 177, in run
    event_handler=cb.event_handler, status_handler=cb.status_handler
  File "/usr/local/lib/python3.7/dist-packages/ansible_runner/interface.py", line 159, in run
    r.run()
  File "/usr/local/lib/python3.7/dist-packages/ansible_runner/runner.py", line 89, in run
    self.status_callback('starting')
  File "/usr/local/lib/python3.7/dist-packages/ansible_runner/runner.py", line 82, in status_callback
    self.status_handler(status_data, runner_config=self.config)
TypeError: status_handler() got an unexpected keyword argument 'runner_config'

ansible 2.7.9

The parameter h is not applied in Playbook mode

In playbook mode, the playbook is executed for all hosts defined in the playbook file (hosts parameter) instead of the devices defined by h parameter.

In controller.py (line 169), ansible_runner.interface.run() is call with host_pattern param
except :
:param host_pattern: The host pattern to match when running in ad-hoc mode.

host_pattern should not be used in playbook mode. you should use limit parameter instead:
:param limit: Matches ansible's --limit parameter to further constrain the inventory to be used

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.