ansible-playbook
給我的錯誤看起來像這樣:如何從劇本中獲得更多可用的錯誤信息?
fatal: [test.example.com]: FAILED! => {"changed": false, "cmd": "./manage.py migrate --noinput
--pythonpath=/srv/virtualenv/myapp/bin/python3", "failed": true, "msg": "\n:stderr: Traceback (most recent call last):\n File \"./manage.py\", line 10, in <module>\n execute_from_command_line(sys.argv)\n File \"/srv/virtualenv/myapp/lib/python3.5/site-packages/django/core/management/__init__.py\", line 354, in execute_from_command_line\n utility.execute()\n File \"/srv/virtualenv/myapp/lib/python3.5/site-packages/django/core/management/__init__.py\", line 303, in execute\n settings.INSTALLED_APPS\n File \"/srv/virtualenv/myapp/lib/python3.5/site-packages/django/conf/__init__.py\", line 48, in __getattr__\n self._setup(name)\n File \"/srv/virtualenv/myapp/lib/python3.5/site-packages/django/conf/__init__.py\", line 44, in _setup\n self._wrapped = Settings(settings_module)\n File \"/srv/virtualenv/myapp/lib/python3.5/site-packages/django/conf/__init__.py\", line 92, in __init__\n mod = importlib.import_module(self.SETTINGS_MODULE)\n File \"/srv/virtualenv/myapp/lib/python3.5/importlib/__init__.py\", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File \"<frozen importlib._bootstrap>\", line 986, in _gcd_import\n File \"<frozen importlib._bootstrap>\", line 969, in
_find_and_load\n File \"<frozen importlib._bootstrap>\", line 956, in _find_and_load_unlocked\nImportError: No module named 'myapp.settings'\n", "path": "/srv/virtualenv/myapp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "state": "absent", "syspath": ["/tmp/ansible_OoxaWI", "/tmp/ansible_OoxaWI/ansible_modlib.zip", "/usr/lib/python2.7", "/usr/lib/python2.7/plat-x86_64-linux-gnu", "/usr/lib/python2.7/lib-tk", "/usr/lib/python2.7/lib-old", "/usr/lib/python2.7/lib-dynload", "/usr/local/lib/python2.7/dist-packages", "/usr/lib/python2.7/dist-packages"]}
當然,我可以複製此並粘貼到ipython
得到的東西更有用的觀點,即
fatal: [test.example.com]: FAILED! => {"changed": false, "cmd": "./manage.py migrate --noinput --pythonpath=/srv/virtualenv/myapp/bin/python3", "failed": true, "msg": "
:stderr: Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/srv/virtualenv/myapp/lib/python3.5/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/srv/virtualenv/myapp/lib/python3.5/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/srv/virtualenv/myapp/lib/python3.5/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/srv/virtualenv/myapp/lib/python3.5/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/srv/virtualenv/myapp/lib/python3.5/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/srv/virtualenv/myapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'myapp.settings'
", "path": "/srv/virtualenv/myapp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "state": "absent", "syspath": ["/tmp/ansible_OoxaWI", "/tmp/ansible_OoxaWI/ansible_modlib.zip", "/usr/lib/python2.7", "/usr/lib/python2.7/plat-x86_64-linux-gnu", "/usr/lib/python2.7/lib-tk", "/usr/lib/python2.7/lib-old", "/usr/lib/python2.7/lib-dynload", "/usr/local/lib/python2.7/dist-packages", "/usr/lib/python2.7/dist-packages"]}
但我像ansible
爲我做。我怎樣才能做到這一點?
這是相關的,但並不像解決我的問題:Ansible playbook shell output
你應該永遠不會看到這樣的錯誤。 Ansible項目在進行堆棧跟蹤時認爲它是一個錯誤,而不是用更易於用戶使用的錯誤捕獲錯誤。在他們的GitHub上提出問題。 – smiller171