Configuring AWX with external AWS Postgres RDS

Hello

I am trying to install AWX 23.8.0 in a AWS EC2 and want to use external Aws Postgres RDS(Engine 1).

I followed the documentation in awx/tools/docker-compose/README.md at 22.5.0 · ansible/awx · GitHub
And I configured

# External Database Settings
 pg_host="awx-pg-12.qsdsdqq000.eu-west-3.rds.amazonaws.com"
 pg_password="*****"
 pg_username="postgres"
 pg_hostname="awx-pg-12"  #DB-IDentifier

and during the installation the job fails

tools_awx_1 | 2024-02-29 09:46:06,251 ERROR    [-] awx.main.cache_clear Encountered unhandled error in cache clear main loop
tools_awx_1 | Traceback (most recent call last):
tools_awx_1 |   File "/awx_devel/awx/main/management/commands/run_cache_clear.py", line 22, in handle
tools_awx_1 |     with pg_bus_conn() as conn:
tools_awx_1 |   File "/usr/lib64/python3.9/contextlib.py", line 119, in __enter__
tools_awx_1 |     return next(self.gen)
tools_awx_1 |   File "/awx_devel/awx/main/dispatch/__init__.py", line 132, in pg_bus_conn
tools_awx_1 |     pg_connection.connect()
tools_awx_1 |   File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
tools_awx_1 |     return func(*args, **kwargs)
tools_awx_1 |   File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/base/base.py", line 270, in connect
tools_awx_1 |     self.connection = self.get_new_connection(conn_params)
tools_awx_1 |   File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
tools_awx_1 |     return func(*args, **kwargs)
tools_awx_1 |   File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
tools_awx_1 |     connection = self.Database.connect(**conn_params)
tools_awx_1 |   File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/psycopg/connection.py", line 728, in connect
tools_awx_1 |     raise ex.with_traceback(None)
tools_awx_1 | psycopg.OperationalError: connection failed: database "awx" does not exist

Doesnt the Awx installation manage the creation of default DB during installation?

When I tried previously with the default config, the Posgtes container was created and all the required DB was installed.

I tested the accessibility of RDS endpoint from EC2 running AWX and its OK.

Hi, you should manually create awx database if you want to use external DB.

The official postgres container image creates default DB during its first startup by referring POSTGRES_USER or POSTGRES_DB environment variables.

This is why awx database is created for bundled PSQL by default, since the default value for POSTGRES_DB is awx.

POSTGRES_USER

This optional environment variable is used in conjunction with POSTGRES_PASSWORD to set a user and its password. This variable will create the specified user with superuser power and a database with the same name.

https://hub.docker.com/_/postgres

POSTGRES_DB

This optional environment variable can be used to define a different name for the default database that is created when the image is first started. If it is not specified, then the value of POSTGRES_USER will be used.

https://hub.docker.com/_/postgres

The AWX installation does not automatically create the database on an external AWS RDS instance. You need to manually create the “awx” database on your RDS instance before running the AWX installation. Ensure the database connection details in the AWX configuration match your RDS settings and that your EC2 instance can connect to the RDS instance over the network.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.