Installer breaks in migrate task, django backend not found.
Update inventory to point to external database host, user, password and database.
Complete the setup.
The migration tasks fails with this error:
kubectl -n awx exec ansible-tower-management -- bash -c awx-manage migrate
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 "/usr/bin/awx-manage", line 11, in <module>
load_entry_point('awx==3.0.0.0', 'console_scripts', 'awx-manage')()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/__init__.py", line 150, in manage
execute_from_command_line(sys.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
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'
command terminated with exit code 1
If you replace the django backend engine it works:
Updated file:
DATABASES = {
'default': {
'ATOMIC_REQUESTS': True,
'ENGINE': 'django.db.backends.postgresql', ### BEFORE CHANGE 'ENGINE': 'awx.main.db.profiled_pg',
'NAME': "{{ pg_database }}",
'USER': "{{ pg_username }}",
'PASSWORD': "{{ pg_password }}",
'HOST': "{{ pg_hostname|default('postgresql') }}",
'PORT': "{{ pg_port }}",
}
}
BROKER_URL = 'amqp://{}:{}@{}:{}/{}'.format(
"{{ rabbitmq_user }}",
"{{ rabbitmq_password }}",
"localhost",
"5672",
"awx")
CHANNEL_LAYERS = {
'default': {'BACKEND': 'asgi_amqp.AMQPChannelLayer',
'ROUTING': 'awx.main.routing.channel_routing',
'CONFIG': {'url': BROKER_URL}}
}
@ikkaro
If you're seeing Error was: No module named 'awx.main.db', that suggests that the code you're running on ansible-tower-management is old (i.e., not devel, as suggested in your report).
This code does exist (and _is_ importable for me) on devel: https://github.com/ansible/awx/tree/devel/awx/main/db
$ echo "from awx.main.db import profiled_pg; print(profiled_pg.__file__)" | awx-manage shell
/awx_devel/awx/main/db/profiled_pg/__init__.py
@ikkaro Are you building your own images here?
No, I'm running without building my images.
I'm now running into the same issue when attempting to install in GKE. I guess that solution is to build the images, rather than pulling them from docker hub?
A-ha! I figured out what was going on with the "'awx.main.db.profiled_pg' isn't an available database backend." error I was getting. If you check out the default "devel" branch of awx from github, it will still attempt to use 3.0.1 docker images (whether built locally, or pulled from docker hub). roles/image_build/tasks/main.yml reads the "awx_version" variable from the file VERSION at the root of the awx repo. Currently, that file contains the string "3.0.1". The solution is to download the tar.gz archive for awx-3.0.1 from the github repo, and use that to deploy, rather than the devel branch.
Sorry for the confusion @skinlayers @ikkaro; we only periodically cut releases and official images, so if you're running the bleeding edge on devel, you definitely need to build your own local images for many things to function.
Most helpful comment
A-ha! I figured out what was going on with the "'awx.main.db.profiled_pg' isn't an available database backend." error I was getting. If you check out the default "devel" branch of awx from github, it will still attempt to use 3.0.1 docker images (whether built locally, or pulled from docker hub). roles/image_build/tasks/main.yml reads the "awx_version" variable from the file VERSION at the root of the awx repo. Currently, that file contains the string "3.0.1". The solution is to download the tar.gz archive for awx-3.0.1 from the github repo, and use that to deploy, rather than the devel branch.