0

问题是什么?

我正面临这个问题:

~ # ansible-playbook test_playbook.yml -vv
ansible-playbook 2.10.6
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/.local/lib/python3.8/site-packages/ansible
  executable location = /root/.local/bin/ansible-playbook
  python version = 3.8.7 (default, Mar  2 2021, 10:13:07) [GCC 10.2.1 20201203]
No config file found; using defaults
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Operations to perform:
  Apply all migrations: admin, API, auth, contenttypes, db, sessions
Running migrations:
  No migrations to apply.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: test_playbook.yml *****************************************************************************************************************************************************************************************************************
2021-03-09 17:47:40,379 ERROR ara.clients.http: Failed to post on /api/v1/playbooks: {'ansible_version': '2.10.6', 'arguments': {'version': None, 'verbosity': 2, 'ask_pass': False, 'private_key_file': None, 'remote_user': None, 'connection': 'smart', 'timeout': 10, 'ssh_common_args': '', 'sftp_extra_args': '', 'scp_extra_args': '', 'ssh_extra_args': '', 'force_handlers': False, 'flush_cache': False, 'become': False, 'become_method': 'sudo', 'become_user': None, 'become_ask_pass': False, 'tags': ('all',), 'skip_tags': (), 'check': False, 'syntax': False, 'diff': False, 'inventory': ('/etc/ansible/hosts',), 'listhosts': False, 'subset': None, 'extra_vars': "Not saved by ARA as configured by 'ignored_arguments'", 'vault_ids': (), 'ask_vault_pass': False, 'vault_password_files': (), 'forks': 5, 'module_path': None, 'listtasks': False, 'listtags': False, 'step': False, 'start_at_task': None, 'args': ('test_playbook.yml',)}, 'status': 'running', 'path': '/root/test_playbook.yml', 'controller': 'ansible-ara.soil.rns.equant.com', 'started': '2021-03-09T16:47:40.373005+00:00'}
[WARNING]: Failure using method (v2_playbook_on_start) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7fd2835ad1f0>): Expecting value: line 1 column 1 (char 0)
1 plays in test_playbook.yml

PLAY [hello world playbook] *****************************************************************************************************************************************************************************************************************
[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7fd2835ad1f0>): 'NoneType' object is not subscriptable

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
task path: /root/test_playbook.yml:2
[WARNING]: Failure using method (v2_playbook_on_task_start) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7fd2835ad1f0>): 'NoneType' object is not subscriptable
ok: [localhost]
[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7fd2835ad1f0>): 'NoneType' object is not subscriptable
META: ran handlers

TASK [Create a file called '/tmp/testfile.txt' with the content 'hello world'.] *************************************************************************************************************************************************************
task path: /root/test_playbook.yml:5
changed: [localhost] => {"changed": true, "checksum": "d2a45e30e96f950a9847849614c40f0526aa7336", "dest": "/tmp/testfile.txt", "gid": 0, "group": "root", "md5sum": "bb22645172345eb28c6ea2c7a0464611", "mode": "0644", "owner": "root", "size": 11, "src": "/root/.ansible/tmp/ansible-tmp-1615308462.0821924-6650-197104859992296/source", "state": "file", "uid": 0}
META: ran handlers
META: ran handlers

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

[WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7fd2835ad1f0>): 'NoneType' object is not subscriptable

ARA 正在运行 我在浏览器上访问 API UI 一切似乎都按预期工作,但每次都会显示此错误,并且 ARA 未获取 ansible 记录我做错了什么?

应该发生什么?

我应该在 ARA 上看到我的剧本记录

我使用以下方式运行服务器:

~ # ara-manage runserver
[ara] Using settings file: /root/.ara/server/settings.yaml
[ara] Using settings file: /root/.ara/server/settings.yaml
2021-03-09 19:24:57,020 INFO django.utils.autoreload: Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
March 09, 2021 - 19:24:57
Django version 2.2.19, using settings 'ara.server.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

设置文件如下图


~/.ara/server # cat settings.yaml
---
# This is a default settings template generated by ARA.
# To use a settings file such as this one, you need to export the
# ARA_SETTINGS environment variable like so:
#   $ export ARA_SETTINGS="/root/.ara/server/settings.yaml"

default:
  ALLOWED_HOSTS:
  - ::1
  - 127.0.0.1
  - localhost
  BASE_DIR: /root/.ara/server
  CORS_ORIGIN_ALLOW_ALL: false
  CORS_ORIGIN_REGEX_WHITELIST: []
  CORS_ORIGIN_WHITELIST:
  - http://127.0.0.1:8000
  - http://localhost:3000
  DATABASE_CONN_MAX_AGE: 0
  DATABASE_ENGINE: django.db.backends.sqlite3
  DATABASE_HOST: null
  DATABASE_NAME: /root/.ara/server/ansible.sqlite
  DATABASE_OPTIONS: {}
  DATABASE_PASSWORD: null
  DATABASE_PORT: null
  DATABASE_USER: null
  DEBUG: false
  DISTRIBUTED_SQLITE: false
  DISTRIBUTED_SQLITE_PREFIX: ara-report
  DISTRIBUTED_SQLITE_ROOT: /var/www/logs
  EXTERNAL_AUTH: false
  LOGGING:
    disable_existing_loggers: false
    formatters:
      normal:
        format: '%(asctime)s %(levelname)s %(name)s: %(message)s'
    handlers:
      console:
        class: logging.StreamHandler
        formatter: normal
        level: INFO
        stream: ext://sys.stdout
    loggers:
      ara:
        handlers:
        - console
        level: INFO
        propagate: 0
    root:
      handlers:
      - console
      level: INFO
    version: 1
  LOG_LEVEL: INFO
  PAGE_SIZE: 100
  READ_LOGIN_REQUIRED: false
  SECRET_KEY: [HIDDEN]
  TIME_ZONE: Europe/Paris
  WRITE_LOGIN_REQUIRED: false


这是我的环境的样子:

~ # env
ARA_API_CLIENT=http
MAIL=/var/mail/root
USER=root
SSH_CLIENT=
SHLVL=1
HOME=/root
SSH_TTY=/dev/pts/0
PAGER=less
https_proxy=http://:8080
LOGNAME=root
http_proxy=http://:8080
TERM=xterm
LC_COLLATE=C
PATH=/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ftp_proxy=http://:8080
LANG=C.UTF-8
ARA_API_SERVER=http://127.0.0.1:8000
SHELL=/bin/ash
PWD=/root
SSH_CONNECTION=
CHARSET=UTF-8
ANSIBLE_CALLBACK_PLUGINS=/root/.local/lib/python3.8/site-packages/ara/plugins/callback

当我以完全详细模式执行剧本时,除了上面的错误之外,我还看到了这些回调异常:

[WARNING]: Failure using method (v2_playbook_on_start) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7f8a33482fd0>): Expecting value: line 1 column 1 (char 0)
Callback Exception:
  File "/root/.local/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 389, in send_callback
    method(*new_args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 290, in v2_playbook_on_start
    self.playbook = self.client.post(
   File "/root/.local/lib/python3.8/site-packages/ara/clients/http.py", line 115, in post
    return self._request("post", endpoint, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/clients/http.py", line 106, in _request
    return response.json()
   File "/usr/lib/python3.8/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
   File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
   File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
   File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
1 plays in test_playbook.yml

[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7f8a33482fd0>): 'NoneType' object is not subscriptable
Callback Exception:
  File "/root/.local/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 389, in send_callback
    method(*new_args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 327, in v2_playbook_on_play_start
    self._submit_thread("global", self._set_playbook_labels, labels)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 247, in _submit_thread
    func(*args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 461, in _set_playbook_labels
    current_labels = [label["name"] for label in self.playbook["labels"]]
[WARNING]: Failure using method (v2_runner_on_ok) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7f8a33482fd0>): 'NoneType' object is not subscriptable
Callback Exception:
  File "/root/.local/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 389, in send_callback
    method(*new_args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 391, in v2_runner_on_ok
    self._submit_thread("task", self._load_result, result, "ok", **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 247, in _submit_thread
    func(*args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 505, in _load_result
    host = self._get_or_create_host(hostname)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 492, in _get_or_create_host
    self.host_cache[host] = self.client.post("/api/v1/hosts", name=host, playbook=self.playbook["id"])
META: ran handlers
[WARNING]: Failure using method (v2_playbook_on_task_start) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7f8a33482fd0>): 'NoneType' object is not subscriptable
Callback Exception:
  File "/root/.local/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 389, in send_callback
    method(*new_args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 368, in v2_playbook_on_task_start
    task_file = self._get_or_create_file(path)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 483, in _get_or_create_file
    "/api/v1/files", playbook=self.playbook["id"], path=path, content=content
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492 `" && echo ansible-tmp-1615314391.2775044-7293-103683122105492="` echo /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492 `" ) && sleep 0'
Using module file /root/.local/lib/python3.8/site-packages/ansible/modules/setup.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-7288inipmqs9/tmppg_94x5d TO /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492/ /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1615314391.2775044-7293-103683122105492/ > /dev/null 2>&1 && sleep 0'
[WARNING]: Failure using method (v2_playbook_on_stats) in callback plugin (<ansible.plugins.callback.ara_default.CallbackModule object at 0x7f8a33482fd0>): 'NoneType' object is not subscriptable
Callback Exception:
  File "/root/.local/lib/python3.8/site-packages/ansible/executor/task_queue_manager.py", line 389, in send_callback
    method(*new_args, **kwargs)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 406, in v2_playbook_on_stats
    self._load_stats(stats)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 547, in _load_stats
    host = self._get_or_create_host(hostname)
   File "/root/.local/lib/python3.8/site-packages/ara/plugins/callback/ara_default.py", line 492, in _get_or_create_host
    self.host_cache[host] = self.client.post("/api/v1/hosts", name=host, playbook=self.playbook["id"])

4

0 回答 0