当前尝试在Kubernetes上安装awx,但是与awx-manage相关的任何命令均失败,并显示Error was: No module named 'awx.main.db'
。我试过通过-/ bin / bash手动将这些命令运行到容器中,但是得到相同的错误。
这些是失败的任务:
- name: Migrate database
shell: |
{{ kubectl_or_oc }} -n {{ kubernetes_namespace }} exec ansible-tower-management -- \
bash -c "awx-manage migrate --noinput"
- name: Check for Tower Super users
shell: |
{{ kubectl_or_oc }} -n {{ kubernetes_namespace }} exec ansible-tower-management -- \
bash -c "echo 'from django.contrib.auth.models import User; nsu = User.objects.filter(is_superuser=True).count(); exit(0 if nsu > 0 else 1)' | awx-manage shell"
register: super_check
ignore_errors: no
changed_when: super_check.rc > 0
- name: create django super user if it does not exist
shell: |
{{ kubectl_or_oc }} -n {{ kubernetes_namespace }} exec ansible-tower-management -- \
bash -c "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('{{ admin_user }}', '{{ admin_email }}', '{{ admin_password }}')\" | awx-manage shell"
no_log: no
when: super_check.rc > 0
- name: update django super user password
shell: |
{{ kubectl_or_oc }} -n {{ kubernetes_namespace }} exec ansible-tower-management -- \
bash -c "awx-manage update_password --username='{{ admin_user }}' --password='{{ admin_password }}'"
no_log: no
register: result
changed_when: "'Password updated' in result.stdout"
容器日志中的完整错误:
Traceback (most recent call last):
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'awx.main.db'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/awx/venv/awx/bin/daphne", line 11, in <module>
sys.exit(CommandLineInterface.entrypoint())
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/daphne/cli.py", line 144, in entrypoint
cls().run(sys.argv[1:])
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/daphne/cli.py", line 174, in run
channel_layer = importlib.import_module(module_path)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/asgi.py", line 37, in <module>
channel_layer = get_channel_layer()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/channels/asgi.py", line 115, in get_channel_layer
django.setup(set_prefix=False)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/models/options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/db/utils.py", line 134, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'awx.main.db.profiled_pg' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: No module named 'awx.main.db'
2019-03-20 16:04:31,541 INFO exited: daphne (exit status 1; not expected)
2019-03-20 16:04:32,546 INFO spawned: 'daphne' with pid 2587
2019-03-20 16:04:33,555 INFO success: daphne entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
答案 0 :(得分:0)
您的容器-awx.main.db.profiled_pg
中似乎缺少数据库后端的模块。那是相当新的代码,但尚未稳定发布。
那是一个issue。尝试遵循该票证的建议:
解决方案是从github存储库中下载awx-3.0.1的tar.gz归档文件,然后使用它而不是devel分支进行部署。